借助油猴插件,在当前网页添加固定按钮
当需要增强当前网页的按钮时,我们需要添加按钮实现特定功能,这个可以使用js代码实现,在代码实现过程中发现,style的一个属性z-index
需要特定方式实现,详见下文:
let Container = document.createElement('div');
Container.id = "sp-ac-container";
Container.style.position="fixed"
Container.style.left="220px"
Container.style.top="20px"
Container.style['z-index']="999999"
Container.innerHTML =`<button id="myCustomize" style="position:absolute; left:30px; top:20px">
浮动按钮
</button>
`
document.body.appendChild(Container);