google-chrome-extension

Set Interval in Google Chrome Extension

痴心易碎 提交于 2020-01-25 04:26:27
问题 I'm writing a google chrome extension that gives the user a new word everyday. This word appears in the popup and is inserted into an array so they can study them later. In my background.js I have the classic setInterval, like below: setInterval(function(){ ...code to get new word and push to array }, (12*3600000)); The problem however is that this functions works on every tab open! So I left it for a day with 10 tabs open and I had 10 new words. How can I have a function within a google

Chrome Native Messaging — Why am I receiving a “Specified native messaging host not found” error?

戏子无情 提交于 2020-01-24 23:27:00
问题 According to the Chrome Native Messaging docs a successful call to connectNative() returns a port, with which you can post messages to a native app (a Mac app). In my case nativeConnect() does return a valid port in my case, but a call to onDisconnected() listener is fired almost immediately. Whenever the listener is fired it prints the "lastError" property to the browser's console, and this gives: Specified native messaging host not found. Why is it doing this? The listener that produces the

Chrome Native Messaging — Why am I receiving a “Specified native messaging host not found” error?

隐身守侯 提交于 2020-01-24 23:26:40
问题 According to the Chrome Native Messaging docs a successful call to connectNative() returns a port, with which you can post messages to a native app (a Mac app). In my case nativeConnect() does return a valid port in my case, but a call to onDisconnected() listener is fired almost immediately. Whenever the listener is fired it prints the "lastError" property to the browser's console, and this gives: Specified native messaging host not found. Why is it doing this? The listener that produces the

How to wait for scripts to be loaded

江枫思渺然 提交于 2020-01-24 22:49:05
问题 I am building a Chrome extension and in my contentScript, I have a function which loops all the <link> elements and check whether it has rel="preconnect" attribute. If true, the icon of the extension will change. The contentScript runs at document start and the function. The function runs onDomLoaded . When the prerender is directly in HTML code, the extension works perfectly. However when prerender is generated by JS, the icon wont change. Probably because the script is not fully loaded when

How to make a basic chrome extension to block certain websites?

為{幸葍}努か 提交于 2020-01-24 21:53:05
问题 What I have so far: manifest.json { "name": "Testing", "version": "0.1", "manifest_version": 2, "description": "Hi there.", "background": { "scripts": ["background.js"] }, "icons": { "128" : "images/test.png" }, "browser_action": { "default_icon": "images/test2.png", "default_title": "test" }, "permissions": [ "webRequest", "webRequestBlocking", "https://www.google.com/*", "http://www.dictionary.com/*" ] } background.js chrome.webRequest.onBeforeRequest.addListener(function(details) { return

Why is requestHeaders undefined?

让人想犯罪 __ 提交于 2020-01-24 21:13:11
问题 I am making a chrome extension which records request headers. In my background.js file I have this code chrome.webRequest.onSendHeaders.addListener(function(res){ res.requestHeaders.forEach(header => { headers.push(header) }) }, {urls : ["<all_urls>"]}) But res.requestHeaders returns undefined (cannot read property forEach of undefined) 回答1: It should be specified in the third parameter of addListener: chrome.webRequest.onSendHeaders.addListener( fn, {urls: ['<all_urls>']}, ['requestHeaders']

How secure is data stored using chrome.storage.local.set

青春壹個敷衍的年華 提交于 2020-01-24 20:25:07
问题 I'm storing options data in a chrome extension using chrome.storage.local.set How secure is that data? Can it be read easily by anyone who has access to the file it is stored in? 回答1: It is not secure, and per the official chrome.storage docs is stored unencrypted in the user's profile folder under their Chrome data directory. You will need to use some additional encryption if you are storing more sensitive data using these APIs. They are stored in a LevelDB database in the following location

Content security policy blocking requests to *://www.google.com/recaptcha/api

僤鯓⒐⒋嵵緔 提交于 2020-01-24 19:38:08
问题 In light of this link , it would seem inline scripts such as are used for inserting a recaptcha object in the page, via <script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=your_public_key"> </script> <noscript> <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response

Auto Focus in Google Chrome extension

耗尽温柔 提交于 2020-01-24 11:17:12
问题 I made a simple Chrome extension - search with a form. When I open the extension, there is no default focus on form, but it requires additional click. Focus is suppose to happen on popup.html form. Now JavaScript .focus() method didn't work, Is there any other way to set default focus for Chrome extensions? HTML: <input type="text" id="mydata" /> JS: document.getElementById('mydata').focus(); 回答1: Try something like this: <html> <head> <script type="text/javascript"> function setFocus() {

Can js code in chrome extension detect that it's executed as content script?

亡梦爱人 提交于 2020-01-24 05:17:09
问题 I have a google chrome extension that shares some code between it's content script and background process / popup. If it some easy and straightforward way for this code to check if it's executed as content script or not? (message passing behavior differs). I can include additional "marker" javascript in manifest or call some chrome fnction unavailable from content script and check for exceptions - but these methods looks awkward to be. Maybe it's some easy and clean way to make this check?