google-chrome-extension

Chrome Extension : Issue with SendMessage

非 Y 不嫁゛ 提交于 2019-12-13 15:13:39
问题 I am trying to change the contents of a page based on the output of a xhr call. I am sending a message from content.js making the xrh call in the background js file and then passing the output to content.js which alters the content of the page. From my content.js file I am doing the following. var s = document.createElement('script'); s.src = chrome.extension.getURL('src/content/main.js'); (document.head || document.documentElement).appendChild(s); In my main.js I am doing chrome.runtime

SendResponse fails when using a Promise

微笑、不失礼 提交于 2019-12-13 14:52:59
问题 In the extension I am building, on click of a button, a request is sent from ChromeUtils.js return new Promise(function(fulfill,reject){ var request = { type : "background.twitterRequestToken", }; chrome.runtime.sendMessage(request, function(response) { if (response) { fulfill(response); } else { reject(response); } }); }); to the background.js which in turn calls an oauth Api to send a request to the remote server. chrome.runtime.onMessage.addListener(function (request, sender, sendResponse)

Dart chrome extension: Listen to chrome api events

£可爱£侵袭症+ 提交于 2019-12-13 14:41:34
问题 To better describe my problem i have created a small example of a chrome extension written in Dart. You can see the code or download the extension on Gist. The problem This example is running fine in Dartium, but when compiled to javascript a typeerror occurs: Uncaught TypeError: undefined is not a function for the line: context['chrome']['runtime']['onMessage'].callMethod('addListener', [onMessageListener]); How far i already am As you may see in the example the functions alert() or console

Does chrome extension api support downloads directly from browsing cache?

孤人 提交于 2019-12-13 13:27:50
问题 I'm implementing a simple web picture grabber, using chrome.downloads api. I grab the image urls in content script, and then call chrome.downloads.download to download them in the background script. It works well, but I want it faster. I find that if users click " save image as " in the context menu of <img> object, the downloading speed is very fast and almost seamless. I think it downloads directly from cache. However, using chrome.downloads seems independent of the loading of <img> objects

Google Chrome: Refused to Execute Inline script

别说谁变了你拦得住时间么 提交于 2019-12-13 13:15:53
问题 In light of change in chrome's content security policy, I have moved all the script in separate files and referencing them in html pages (background and popup) for my chrome extension. But I still get the following message Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:". This is my background page <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text

Load iframe into the page, using Chrome Extension content script

北城余情 提交于 2019-12-13 13:11:42
问题 I am able to add HTML/CSS dynamically into the page using a content script. But I tried adding an iframe tag, and ran into a little bit of trouble. Here is my code: const myIFrame = ` <iframe src="${modalIFrameURL}"></iframe> `; let div = document.createElement('div'); div.style.zIndex = 9999999; div.innerHTML = myIFrame; document.body.insertBefore(div, document.body.firstChild); note the modalIFrameURL value is: chrome-extension://omelijcoklpokoeobkpepoipjpbakoeo/modal-iframe.html This is

Paste the string to a text box. Chrome Extension

痞子三分冷 提交于 2019-12-13 12:51:41
问题 I am making a chrome extension that requires copy and pasting text. Suppose a user selects some text on any webpage, it should be copied into a variable and when the user presses ctrl+3, (if in a textbox or somewhere where our normal ctrl+v works) it should paste it. A normal copy paste tool but with different shortcuts. Currently my script has this function: I am retrieving the data correctly but don't know how to paste it. var copy_paste1; document.onkeydown = function(evt) { evt = evt ||

Allowed Keyboard Shortcuts for Chrome Extensions

风格不统一 提交于 2019-12-13 12:16:46
问题 When you creating a Chrome browser extension, you may suggest keyboard shortcuts by implementing the chrome.commands API. Is there a documented list of allowed key combinations? Chrome seems to reject virtually every combination I offer despite the fact that I know they are not used by any of the systems I'm targeting. I'm aware of the keyboard shortcuts listed here, but shortcuts not appearing on this list still do not work. 回答1: The documentation is quite precise in that respect. I will

How to hook chrome extension to network browser traffic

偶尔善良 提交于 2019-12-13 12:13:47
问题 I'm trying to write a chrome extension which intercepts network traffic and modify the data. I would appreciate if someone can tell me exactly which API I should use for this and where I can find the documentation. 回答1: Make use of the webRequest API and have a look at their events. Create a manifest with permissions activeTab to get permissions for the current tab on which you are on, and the url pattern you wish the extension to be enabled for. The webRequestBlocking permission needs to be

Using local storage in Chrome as a DB?

南楼画角 提交于 2019-12-13 12:13:11
问题 I'm having success setting/getting data via local storage. Essentially I'm building a reminder extension/geo-location that allows a user to save the url, their geo-location, and title of the url. 3 pieces of data needs to be saved each time. I'm using JSON.stringfy and JSON.parse to do this. Here is where I'm stuck: How do I save each entry from the user without writing over the last entry in local storage? Each time I save the url it doesn't save it in local storage as a new entry. It just