content-script

How to to initialize keyboard event with given char/keycode in a Chrome extension?

孤街浪徒 提交于 2019-11-26 22:25:03
问题 I'm developing a Google Chrome extension which simulates keyboard events on a web-page. I found that event.initKeyboardEvent() does not work properly because of this webkit bug and I also found some workarounds, e.g. SO Question However, defining properties on event object is not working because extension's content script has its own "parallel world" so properties defined in content script are not visible to web-page script. My only and last hope that DOM 4 Event Constructors work in Google

Injecting multiple scripts through executeScript in Google Chrome

孤街醉人 提交于 2019-11-26 19:41:15
问题 I need to programmatically inject multiple script files (followed by a code snippet) into the current page from my Google Chrome extension. The chrome.tabs.executeScript method allows for a single InjectDetails object (representing a script file or code snippet), as well as a callback function to be executed after the script. Current answers propose nesting executeScript calls: chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.executeScript(null, { file: "jquery.js" },

How to trigger a Chrome extension, content-script for a given hash in the URL?

守給你的承諾、 提交于 2019-11-26 17:24:44
问题 My matches scheme: "content_scripts" : [ { "matches" : [ "https://stackoverflow.com/questions#epic*" ], "js" : ["silly.js"] } ], So if the user went to a webpage (like https://stackoverflow.com/questions) then added #epic it would go to https://stackoverflow.com/questions#epic but would have #epic on the end of the URL, which would activate the content script silly.js . That's what's supposed to happen, but that doesn't work. 回答1: See Content scripts, Match Patterns. Match patterns do not

Chrome extension: Communication between content script and background.html

◇◆丶佛笑我妖孽 提交于 2019-11-26 17:10:55
问题 I am new to Chrome extensions. I am trying to communicate between the content script and the background.html page. The background.html sends a request, " hello ", to the content script and the content script should respond back with " hello background " alert. But it's just not happening. My background.html code is: function testRequest() { chrome.tabs.getSelected(null, function(tab) { chrome.tabs.sendRequest(tab.id, {greeting: "hello"}); }); } content.js code: chrome.extension.onMessage

My CSS is not getting injected through my content script

与世无争的帅哥 提交于 2019-11-26 16:23:22
Can anyone explain this to me. I'm trying to inject a CSS file onto a webpage using the content_script with Google extensions, but my css file never gets added to the webpage. Can someone tell me what I'm doing wrong and help me fix it? thanks Manifest: { "name": "Extension", "version": "0", "description": "", "permissions": ["tabs", "http://*/*", "https://*/*", "file:///*/*"], "content_scripts": [ { "matches": [ "http://*/*", "https://*/*", "file:///*/*"], "css": ["myStyles.css"], "js": ["myScript.js"], "all_frames": true } ] } myStyles.css #test { margin: 0 10px; background: #fff; padding:

Chrome extension: accessing localStorage in content script

☆樱花仙子☆ 提交于 2019-11-26 11:02:34
So, I have an options page where the user can define certain options and it saves it in localStorage: options.html Now, I also have a content script that needs to get the options that were defined in the options.html page, but when I try to access localStorage from content script, it doesn't return the value from options page. How do I make my content script get values from localStorage, from options page or even the background page? Mohamed Mansour Update 2016: Google Chrome released the storage API: http://developer.chrome.com/extensions/storage.html It is pretty easy to use like the other

Chrome extension: Run on all google domains and a specific page

对着背影说爱祢 提交于 2019-11-26 09:55:34
问题 I want my content script to match all google domains, and a specific page. I know this is not possible. Manifest.json \"content_scripts\": [{ \"matches\": [ ,\"*://www.google.*\" ,\"*://www.youtube.com/*\" ,\"*://readthedocs.org/*\"] , .... Is there another way to do this? Just wanted to make sure before I list all domains Google has :) 回答1: Listing all Google domains is not that difficult, because Google has published a list of all public Google domains at http://www.google.com/supported

Access window variable from Content Script [duplicate]

99封情书 提交于 2019-11-26 09:30:01
问题 This question already has answers here : Chrome extension - retrieving global variable from webpage (5 answers) Hijacking a variable with a userscript for Chrome (1 answer) Closed 5 years ago . I have a Chrome Extension that is trying to find on every browsed URL (and every iframe of every browser URL) if a variable window.my_variable_name exists. So I wrote this little piece of content script : function detectVariable(){ if(window.my_variable_name || typeof my_variable_name !== \"undefined\"

Chrome extension adding external javascript to current page's html

我只是一个虾纸丫 提交于 2019-11-26 06:19:14
问题 I am adding some external JavaScript to the end of the page via my chrome extension. The external JavaScript then tries to post some data back to the server, however that is not taking place. The JavaScript wants to get the url of the current page and the referrer and post it back to the server. Can anyone please advice me what is wrong here and how can I if not possible this way can I post data from the current page back to the server. manifest.json { \"name\": \"Website Safety\", \"version\

Chrome extension is not loading on browser navigation at YouTube

爱⌒轻易说出口 提交于 2019-11-26 01:47:35
问题 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\