google-chrome-extension

Why doesn't chrome.tabs.query() return the tab's URL when called using RequireJS in a Chrome extension?

眉间皱痕 提交于 2019-12-18 11:09:29
问题 I have a simple Chrome extension that adds a browser action. When the extension's popup is opened, it needs to access the current tab's URL. Since it doesn't need access to all the tabs, I just have the activeTab permission specified in the manifest: { "manifest_version": 2, "name": "RequireJS Test", "version": "0.0.1", "description": "Test RequireJS and the activeTab permission.", "permissions": [ "activeTab" ], "browser_action": { "default_popup": "popup.html" }, "web_accessible_resources":

Accessing iframes from a Chrome content-script extension

被刻印的时光 ゝ 提交于 2019-12-18 11:08:55
问题 I'm writing a Chrome extension that needs to alter a popular web app when loaded. Unfortunately, most of the UI of that web app is rendered inside an iframe, and although the address of that iframe matches my content_scripts match declaration, the user script only gets invoked for the top frame. Q: Is there a method of accessing HTML rendered inside an iframe from a Chrome content script extension? If yes, what permissions and other manifest options should I specify? Thanks. 回答1: I've

How do I perform a shell execute in a chrome extension?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 10:56:24
问题 I'm not finding a way to do this in the chrome.* API or even the experimental. It doesn't run through wscript so ActiveXObject("Shell.Application") isn't allowed. I fear that my only option is to build a dll with NPAPI but I wanted to see if there was a simpler way. 回答1: If you want to do anything Natively, you need to use NPAPI. That allows you to run code outside the sandbox for your extensions. http://code.google.com/chrome/extensions/npapi.html 回答2: To update this for a fellow wary

Using AngularJS in a Google Chrome extension

Deadly 提交于 2019-12-18 10:35:40
问题 I am trying to use the Google developer AngularJS library in an extension popup, but I get an error. Error: Code generation from strings disallowed for this context at Function (unknown source) at Jb (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:74:18) at k (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:62:357) at Jc (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb/lib/angular.js:64:37) at Lc (chrome-extension://jambnlbfljcfpomlclcgphfmkjfiphkb

How to get my extension's id from JavaScript?

假装没事ソ 提交于 2019-12-18 10:17:11
问题 I'm writing a Chrome extension, I need to get my extension's id in my code, so I don't need to change it manually every time. How can I do this? 回答1: You can get it like this (no extra permissions required) in two different ways: Using runtime api: var myid = chrome.runtime.id; Using i18n api: var myid = chrome.i18n.getMessage("@@extension_id"); but you don't need it for opening pages, as chrome.tabs.create() (and some others) understand relative paths. So to open index.html from your

Chrome extensions - Other ways to read response bodies than chrome.devtools.network?

半世苍凉 提交于 2019-12-18 10:11:49
问题 I'd like to read (not modify) the response body for all requests that match some pattern in a Chrome extension. I'm currently using chrome.devtools.network.onRequestFinished, which gives you a Request object with a getContent() method. This works just fine, but of course requires the devtools to be open for the extension to work. Ideally the extension would be a popup, but chrome.webRequest.onCompleted doesn't seem to give access to the response body. There is a feature request to allow the

Chrome extension message being passed as object

a 夏天 提交于 2019-12-18 09:44:45
问题 I'm sending a message from the content script to the background page. The message is a URL which then gets ajax parsed in the background. When I console.log the data retrieved into background.js the console log is pure html, but when I send the message back to my content script the message is suddenly in an object, and I'm not sure why. Here is my code: Content_Script.js: chrome.runtime.sendMessage({greeting: URL}, function(response) { console.log(response.farewell); //logs an object: Object

Send DOM node object via chrome.tabs.sendMessage

给你一囗甜甜゛ 提交于 2019-12-18 09:37:47
问题 I am writing a Chrome extension. I need to pass an element object from the content script to the background script. The goal: The extension is about record and replay user actions. The data is saved on extension`s localstorage on different object for each tab (by tab ID). The data structure is a list of {x: x, y:y, element: element} When the user wants to replay, I am using a loop for each object on the list and using .click() on the element Code in content script: The function that sends a

Chrome extension error with 'onCommand'

大憨熊 提交于 2019-12-18 09:32:02
问题 I'm getting the error "Uncaught TypeError: Cannot read property 'onCommand' of undefined" while running a Chrome Extension with the following content: manifest.json: { "name": "Test", "description": "Key command test.", "version": "1.0", "manifest_version": 2, "content_scripts": [ { "js": ["background_test.js"], "matches": [ "http://*/*", "https://*/*"] }], "commands": { "Ctrl+M": { "suggested_key": { "default": "Ctrl+M", "mac": "Command+M" }, "description": "Ctrl+M." }, "Ctrl-L": {

jQuery $(document).off() not working in Chrome extension

坚强是说给别人听的谎言 提交于 2019-12-18 09:31:53
问题 I've created a Chrome Extension based on https://thoughtbot.com/blog/how-to-make-a-chrome-extension (look at the end for the completed files) I've made two changes: I used jQuery 3.1.1 minimized instead of the older one given in the page above, and I changed content.js: chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { if( request.message === "clicked_browser_action" ) { $(document).off("touchmove mousewheel mousemove scroll"); } } ); The $(document).off()