使 Google Chrome 扩展程序自动弹出
Make Google Chrome Extension Automatically Pop Up
我正在制作 google chrome 扩展。有没有办法使用 javascript 让扩展在每次切换到新标签时自动弹出而无需单击图标?
如果您希望将 javascript 注入每个页面(然后您决定是否要从那里进行页面内弹出)。您将使用内容脚本。
https://developer.chrome.com/docs/extensions/mv3/content_scripts/#functionality
我有一个解决方法给你,它是创建一个粘性对话框容器,从你的contents.js创建它,使容器样式固定位置。
在 ES5 语法中:
var container = document.createElement('div')
container.style.position = "fixed"
container.style.height = "50px"
container.style.width = " 100px"
container.style.top = "0px"
container.style.right = "0px"
container.style.border = "1px solid black"
container.style.backgroundColor = "white"
document.body.appendChild(container)
我正在制作 google chrome 扩展。有没有办法使用 javascript 让扩展在每次切换到新标签时自动弹出而无需单击图标?
如果您希望将 javascript 注入每个页面(然后您决定是否要从那里进行页面内弹出)。您将使用内容脚本。
https://developer.chrome.com/docs/extensions/mv3/content_scripts/#functionality
我有一个解决方法给你,它是创建一个粘性对话框容器,从你的contents.js创建它,使容器样式固定位置。
在 ES5 语法中:
var container = document.createElement('div')
container.style.position = "fixed"
container.style.height = "50px"
container.style.width = " 100px"
container.style.top = "0px"
container.style.right = "0px"
container.style.border = "1px solid black"
container.style.backgroundColor = "white"
document.body.appendChild(container)