google-chrome-extension

chrome extension: sharing an object between content scripts and background script

♀尐吖头ヾ 提交于 2019-12-21 10:15:58
问题 I am developing a chrome extension that uses jQuery/Zepto in the content script. Now, the extension is meant to run on every website, which means a copy of jQuery/Zepto is loaded on each tab the user opens. Is there a way to share the jQuery/Zepto object between the various content scripts? I know content scripts can communicate with the background script. I was hoping to be able to let the background script have access to the jQuery object and return a reference to it, to each of the content

Chrome Extension: Permissions to manipulate content of data URIs

南楼画角 提交于 2019-12-21 09:15:21
问题 I am working on a Chrome extension that needs to inject scripts into data:-URI pages. When trying to execute the javascript I get an exception: Error during tabs.executeScript: Cannot access contents of url "data:text/html;charset=utf-8, … ". Extension manifest must request permission to access this host. But which permission would work for me? I tried data:* , <all_urls> , *://*/* - none of these worked. Also the activeTab permission did not do the trick. Any ideas? 回答1: It's currently a

$x() function is not defined inside a Chrome extension, content script

假装没事ソ 提交于 2019-12-21 09:07:32
问题 $x("//a[contains(@href,'.jpg')]"); works as expected from the developer tools command prompt. But, when in an extension's content-script I get a ' $x is not defined '. Why is this not available in a content-script or is there a special way of accessing it inside a content-script / Chrome extension? I'm using Chrome 22 on Debian. 回答1: $x() is not part of the run-time environment of a web page or content script. It is a tool that is part of the Command Line API for Chrome's DevTools. To use

chrome.runtime.connectNative generates Uncaught TypeError: undefined is not a function

喜欢而已 提交于 2019-12-21 08:24:34
问题 I did write an chrome extension that calls this connect() function to connect to a local C++ program: function connect() { console.log("test1"); //port = chrome.extension.connectNative('com.a.chrome_interface'); port = chrome.runtime.connectNative('com.a.chrome_interface'); port.onMessage.addListener(onNativeMessage); port.onDisconnect.addListener(onDisconnected); console.log("test5"); } I can see the test1 in the Console, but afterwards I got the error Uncaught TypeError: undefined is not a

loading script to google chrome extension

£可爱£侵袭症+ 提交于 2019-12-21 07:23:11
问题 I'm trying to create new extensions but I'm having a problem when I include the JavaScript: { "name": "<name>", "version": "1.0", "description": "<description>", "default_icon": "icon.png", "content_scripts": [ { "matches": ["http://*.com"], "js": ["script.js"] } ], "permissions": [ "http://*.com/" ] } I'm having this error: could not load extension from <path> Invaild value for 'content_scripts[0].matches[0]':Empty path 回答1: You have a invalid matches URL - content script match patterns need

chrome.tabs.executeScript thows error “Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url …”

流过昼夜 提交于 2019-12-21 07:13:58
问题 So I am trying to execute a script from external source like www.script.google.com in background.js. But I get this error - Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "chrome-devtools://devtools/bundled/devtools.html?&remoteBase=https://chrome…&dockSide=undocked&toolbarColor=rgba(223,223,223,1)&textColor=rgba(0,0,0,1)". Extension manifest must request permission to access this host. What i am doing is sending message from popup.js to background

Chrome error when embedding video url with iframe [duplicate]

泪湿孤枕 提交于 2019-12-21 07:07:09
问题 This question already has answers here : Google Chromecast sender error if Chromecast extension is not installed or using incognito (5 answers) Closed 4 years ago . When I embed some url into page with iframe I'm getting the following error's in chrome console. Why is this happening? GET chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js net::ERR_FAILEDfj @ www-embed-player-new.js:151ej @ www-embed-player-new.js:151dj @ www-embed-player-new.js:151ij @ www-embed-player-new.js

Add CSS to pages through a CSS file

為{幸葍}努か 提交于 2019-12-21 06:49:25
问题 I was wondering if it was possible to add CSS to pages through a CSS file, similarly to adding JS to pages through a JS file (contentscript). So, I could just define what pages said CSS file would work on and then it would take effect just like a contentscript. I understand that it is possible to add CSS through a JavaScript file, but it would be more convenient to do it this way instead if possible. If it's not possible, then of course I must use contentscript, but I would first like to know

How to capture touch pad input

£可爱£侵袭症+ 提交于 2019-12-21 06:48:55
问题 I've looked everywhere for how to capture touch pad input for laptops but I can't seem to find anything for Chrome extensions/JavaScript. Question: how can I capture the number of fingers down (not clicked, just down and potentially moving as you would with a mouse), their corresponding x,y coordinates, and their corresponding up events, for a touch pad on a laptop? Clarifications: I'm not interested in detecting touch screen events. Just touch pad events. Can assume the touch pad lives on 3

Simulating keydown event in Chrome

痞子三分冷 提交于 2019-12-21 06:30:27
问题 I am trying to simulate keydown event in Google chrome console. The site of my interest is web.whatsapp.com and the element of concern is document.getElementsByClassName("input-search")[0]; What I am trying to do is that as one types some text in that field, the contact list shown below that field gets updated with contacts containing the content in that text field. Before trying anything else, I just set focus to this text field using this answer. Things I tried are: https://stackoverflow