content-script

Remove a “onmousedown” event from a DOM element via content script in Google Chrome extension

那年仲夏 提交于 2019-12-24 12:24:39
问题 I'm trying to write a Google Chrome extension that removes the onmousedown event from a <a> tag on a website. Earlier that site used to have onmousedown event as part of the DOM so I could easily remove it via content script by calling element.removeAttribute("onmousedown") . But now, they add that event via javascript so it's not possible for me directly remove that event via content script as it runs in a different javascript context. PS: I'm specifically talking about onmousedown event on

Text gets set in Google Groups, post-message body but does not display?

南笙酒味 提交于 2019-12-24 02:34:16
问题 My extension, in a content script, writes to the subject and message body of the Google Groups "New Topic" page. The updated subject is displayed just fine; it's of input type "text", so everything is easy. The body, however, is a div representing a TextBox, and when I write to it, the update doesn't appear: (Click for a larger image.) I tried setting the focus to the field first, but that had no effect. 回答1: How are you trying to set the text? Show your code! A typical way to initially set a

Browser extensions: how can injecting javascript code into a page work without conflicts?

我的未来我决定 提交于 2019-12-23 12:46:30
问题 I have started developing browser extensions. I noticed a common concept is that the extension can inject JS code into the current browser tab. I am a bit puzzled of how that doesn't cause issues on a regular basis. I mean, how can things still work if I inject version x of JQuery (through my browser extension) in a page that has already included version y of JQuery? Won't there be a conflict for the $() function? How is it possible things go that smoothly? Is there any particular technique

Can I use an external array to match URLs for content script injection?

烂漫一生 提交于 2019-12-23 00:44:11
问题 I'm working on a chrome extension where I'd like to inject a content script into a list of urls. Usually I'd use the regular syntax: { "name": "My extension", ... "content_scripts": [ { "matches": ["http://www.google.com/*"], "css": ["mystyles.css"], "js": ["jquery.js", "myscript.js"] } ], ... } But for the match patterns I'd like to pull the array from a server. Is there a way to programmatically set the "matches" array (from the background.js file for example)? 回答1: As far as I know, you

Can I use an external array to match URLs for content script injection?

感情迁移 提交于 2019-12-23 00:44:09
问题 I'm working on a chrome extension where I'd like to inject a content script into a list of urls. Usually I'd use the regular syntax: { "name": "My extension", ... "content_scripts": [ { "matches": ["http://www.google.com/*"], "css": ["mystyles.css"], "js": ["jquery.js", "myscript.js"] } ], ... } But for the match patterns I'd like to pull the array from a server. Is there a way to programmatically set the "matches" array (from the background.js file for example)? 回答1: As far as I know, you

I set geolocation permission in the manifest, but every page still asks to share location

旧巷老猫 提交于 2019-12-22 13:57:22
问题 I'm using a content-script in a chrome extension that I'm writing. I included geolocation in my list of permissions, but on every webpage I still get asked if I want to share my location. I thought if I set geolocation in the list of permissions, I would avoid this? Here's the relevant code from my manifest.json : "permissions": ["geolocation"], "content_scripts": [ { "matches": ["<all_urls>"], "js": ["main.js"] } ] And how I'm using it: navigator.geolocation.getCurrentPosition(function

Unable to view content script references in the developer tools window

大城市里の小女人 提交于 2019-12-22 06:49:26
问题 When I view my extension with the developer tools, I only see the generated background file, background.js; my content script doesn't appear under the content scripts tab. Any ideas why? The relevant part of the manifest looks like this: "content_scripts": [{ "run_at": "document_end", "js": ["postMsg.js"], "matches": ["https://groups.google.com/forum/*"] }], postMsg.js gets injected into the page, but never appears in the developer tool window, so I'm unable to debug it. 回答1: As long as you

Dynamic loading of content script (chrome extension)

巧了我就是萌 提交于 2019-12-22 04:50:34
问题 I have an chrome extension, with 2 content script injected by manifest and one background script. { "manifest_version": 2, "name": "Test", "permissions": [ "tabs", "<all_urls>", "activeTab", "storage" ], "content_scripts": [ { "matches": ["http://*/*", "https://*/*"], "js": [ "content/autofill/lib_generic.js", "content/autofill/lib.js"], "run_at": "document_end" } ], "web_accessible_resources": [ "content/specific_scripts/*" ], "background": { "scripts": ["background.js"], "persistent": false

chrome extension to Send Message from popup to content script

北战南征 提交于 2019-12-21 12:06:29
问题 I,am developing an extension in which i have to extract data from linkedin profile page when user press button on popup. I,am passing message from the popup.js page to contentscript and in response i will get data extracted from linkedin profile page by contentscript so that i can display it in popup.html. But I,am getting error when i inspected the popup.html. The error is: Port: Could not establish connection. Receiving end does not exist. lastError:29 Error in event handler for 'undefined'

$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