content-script

Chrome extension code vs Content scripts vs Injected scripts

强颜欢笑 提交于 2019-11-26 01:34:51
问题 I am trying to get my Chrome Extension to run the function init() whenever a new page is loaded, but I am having trouble trying to understand how to do this. From what I understand, I need to do the following in background.html: Use chrome.tabs.onUpdated.addListener() to check when the page is changed Use chrome.tabs.executeScript to run a script. This is the code I have: //background.html chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { chrome.tabs.executeScript(null,

Insert code into the page context using a content script

99封情书 提交于 2019-11-25 22:51:05
问题 I\'m learning how to create Chrome extensions. I just started developing one to catch YouTube events. I want to use it with YouTube flash player (later I will try to make it compatible with HTML5). manifest.json: { \"name\": \"MyExtension\", \"version\": \"1.0\", \"description\": \"Gotta catch Youtube events!\", \"permissions\": [\"tabs\", \"http://*/*\"], \"content_scripts\" : [{ \"matches\" : [ \"www.youtube.com/*\"], \"js\" : [\"myScript.js\"] }] } myScript.js: function state() { console

Chrome extension is not loading on browser navigation at YouTube

无人久伴 提交于 2019-11-25 22:26:13
Let's say I have an extension that loads when you arrive at a YouTube video page.I have noticed that when one navigates back and forth using the Chrome buttons, the extension most probably won't load. As an example, I have 2 files, the manifest: { "name": "back forth", "version": "0.1", "manifest_version": 2, "description": "back forth", "permissions": ["storage", "*://www.youtube.com/watch*"], "content_scripts": [ { "matches": ["*://www.youtube.com/watch*"], "js": ["contentscript.js"] } ] } and the contentscript alert("loaded"); The alert does not always show up when navigating back and forth