google-chrome-extension

How to import ES6 modules in content script for Chrome Extension

主宰稳场 提交于 2019-12-17 09:22:18
问题 In Chrome 61 , support for modules in JavaScript was added. Right now I am running Chrome 63. I am trying to use import/export syntax in Chrome extension content script to use modules. In manifest.json : "content_scripts": [ { "js": [ "content.js" ], } ] In my-script.js in same directory as content.js 'use strict'; const injectFunction = () => window.alert('hello world'); export default injectFunction; In content.js 'use strict'; import injectFunction from './my-script.js'; injectFunction();

Extension refuses to load the script due to Content Security Policy directive

狂风中的少年 提交于 2019-12-17 08:38:24
问题 Following is my code of HTML Scripts: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="background.js"></script> HTML: <button name="btnlogin" id="btnlogin">Login</button><br/><br/> and following is js $(document).ready(function(){ document.getElementById("#btnlogin").click(function(){ alert("s"); }); }); manifest file: { "manifest_version": 2, "name": "One-click Kittens", "description": "This extension demonstrates a 'browser action' with

Checkbox Check Event Listener

陌路散爱 提交于 2019-12-17 08:18:07
问题 Recently I have been working with the Chrome Plugin API and I am looking to develop a plugin which will make life easier for me for managing a website. Now what I wish to do is to fire an event when a certain checkbox is checked. As this website does not belong to me I cannot change the code therefore I am using the Chrome API. One of the main problems is that rather than there being an ID, there is a Name. I was wondering if I could fire the function once the certain checkbox with the 'name'

Inspect chrome.storage.sync while debugging Chrome extension

末鹿安然 提交于 2019-12-17 07:50:33
问题 Chrome DevTools has a handy inspector for Local Storage and Session Storage, but is there nothing to inspect chrome.storage.sync? chrome://sync-internals/ doesn't seem to display the actual contents of the synchronized storage per extension. 回答1: Storage Area Explorer extension provides a UI for viewing, editing, clearing, importing and exporting of chrome.storage.local , chrome.storage.sync , localStorage and sessionStorage : 回答2: A poor workaround is to call get and obtain all the stored

Inspect chrome.storage.sync while debugging Chrome extension

a 夏天 提交于 2019-12-17 07:50:29
问题 Chrome DevTools has a handy inspector for Local Storage and Session Storage, but is there nothing to inspect chrome.storage.sync? chrome://sync-internals/ doesn't seem to display the actual contents of the synchronized storage per extension. 回答1: Storage Area Explorer extension provides a UI for viewing, editing, clearing, importing and exporting of chrome.storage.local , chrome.storage.sync , localStorage and sessionStorage : 回答2: A poor workaround is to call get and obtain all the stored

Enabling Chrome Extension in Incognito Mode via CLI flags?

断了今生、忘了曾经 提交于 2019-12-17 07:50:10
问题 I'm using selenium to test a chrome extension and part of the extension requires the user to be in incognito mode. Currently, I've not been able to enable the extension to be allowed in incognito mode upon startup except by adding the argument user-data-dir=/path/to/directory . The problem with this is that it loads the extension from the depths of my file system, rather than in a way I can check into git. I've also tried navigating selenium to the chrome extensions settings page but it seems

Enabling Chrome Extension in Incognito Mode via CLI flags?

僤鯓⒐⒋嵵緔 提交于 2019-12-17 07:50:08
问题 I'm using selenium to test a chrome extension and part of the extension requires the user to be in incognito mode. Currently, I've not been able to enable the extension to be allowed in incognito mode upon startup except by adding the argument user-data-dir=/path/to/directory . The problem with this is that it loads the extension from the depths of my file system, rather than in a way I can check into git. I've also tried navigating selenium to the chrome extensions settings page but it seems

How to use GM_xmlhttpRequest in Injected Code?

血红的双手。 提交于 2019-12-17 07:41:31
问题 I am writing a userscript that is injected into a webpage. The script reads some data from a web-server and I want to send messages to a listening application to react to the data. For now, all I'm doing is trying to send a string command to my listening application and see if I can read it. My code worked before it was injected, but afterwards I get an "undefined reference error". I suspect that this has something to do with this "Greasemonkey access violation". However, I have been unable

Get JSON in a Chrome extension

江枫思渺然 提交于 2019-12-17 07:31:20
问题 Small problem with my chrome extension. I just wanted to get a JSON array from another server. But manifest 2 doesn't allow me to do it. I tried specify content_security_policy , but the JSON array is stored on a server without SSL cert. So, what should I do without using manifest 1? 回答1: The CSP cannot cause the problem you've described. It's very likely that you're using JSONP instead of plain JSON. JSONP does not work in Chrome, because JSONP works by inserting a <script> tag in the

Unchecked runtime.lastError when using Chrome API

試著忘記壹切 提交于 2019-12-17 07:29:12
问题 I use chrome.fileSystem API in my app to open a file. When I click the Cancel button of the file chooser dialog, an error occurs: Unchecked runtime.lastError while running fileSystem.chooseEntry : User cancelled How to fix this error? 回答1: This error is not important in this case, but I'll explain it and how to get rid of it. What is this error? Chrome APIs are mostly asynchronous: you have a callback that is called when the operation completes. In case of chrome.fileSystem.chooseEntry , the