Chrome扩展程序在特定页面上弹出 [英] Chrome extension pop up on specific pages
问题描述
我正在开发google chrome扩展程序,我想在特定的网页上弹出此窗口.我不希望功能警报发出通知,我希望在访问某些站点时自动打开整个扩展程序.有什么想法吗?预先谢谢你.
I am developing a google chrome extension and I want to make this pop up on specific web pages. I dont want the function alert to give notifications, I want the whole extension to open automatically when I visit certain sites.Any ideas? Thank you in advance.
推荐答案
在内容脚本中,您可以运行由onload事件触发的一些代码,该代码可以执行以下操作:
In a content script, you can run some code triggered by the onload event, which could do something like:
someExistingElement.append(myPopUp);
或
parentElement.insertBefore(myPopUp, parentElement.firstChild);
您的弹出窗口可能包含许多内部节点,因此,如果要避免通过一系列createElement语句(几乎可以肯定的话)一次将它们添加到DOM中,则可以在模板中构造弹出窗口,然后一步将整个模板添加到DOM.
Your popup likely contains many internal nodes, so if you want to avoid adding these to the DOM one at a time with a series of createElement statements (which you almost certainly do), you can constuct the popup in a template and then add the whole template to the DOM in one step.
(请参阅: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals )
这篇关于Chrome扩展程序在特定页面上弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!