google-chrome-extension

chrome extension: switching from localstorage to chrome.storage.local

≡放荡痞女 提交于 2019-12-25 04:35:09
问题 I finally got one of my first JS scripts running as planned in Firefox. Now I need to switch to chrome.storage because it will otherwise not run in my extension. Basically I want to update a Value in a HTML file, which can be changed by input in a submission box. You are very welcome to pick around in my code, and tell me what is totally abnormal. But I am quite new to JS, and am simply trying to get this to work. Since this worked with localstorage, I guess I have to get it to work with

Pass Variable to Badge Text in Chrome Extension

时光毁灭记忆、已成空白 提交于 2019-12-25 04:22:57
问题 I have built an extension that grabs some info from a div on a page and stores it in a variable called 'div'. I now need to pass that value into my background.js file so that I can update the badge to reflect the text in that variable. I have read through the sendMessage info but every time I add the line of code to my page it seems to break the extension so I am definitely doing something wrong. Here is the code without the setBadgeText info in it (currently functioning). getQueue.js var

Access extension data on other pages

我与影子孤独终老i 提交于 2019-12-25 04:16:14
问题 I want to save some value (say userid) from my extension and then want to access it on other pages. I cannot do it using cookie because I can access cookie only within the extension. Is there a way to do that? 回答1: I am sorry, it might just be me being thick but I still don't really understand what you are trying to do. If you are wanting to create a variable that persists across different domains, you need to use chrome.storage. It is similar to HTML5 localStorage but with some significant

How to replace a piece of HTML with another piece of HTML on a page? [duplicate]

你说的曾经没有我的故事 提交于 2019-12-25 04:15:58
问题 This question already has an answer here : How to replace email addresses with mailto links in a live web page? (1 answer) Closed 4 years ago . I'm making a simple browser extension which is supposed to be used for links addition on a page. The extension should to find text occurrences with references to laws and wrap them in links to corresponding pages with texts of laws. For example, the reference " chapter 1 of Some Law " in a text " The topic covered in the chapter 1 of Some Law " should

Excluding domains from content_scripts in manifest.json doesn't work for CSS files?

半腔热情 提交于 2019-12-25 04:15:48
问题 I want to write a chrome extension to force all websites to use given CSS style except Gmail page. However the following code from content scripts in manifest.json doesn't work (Gmail page will still use the style given in font.css ). "content_scripts": [{ "matches": ["http://*/*", "https://*/*"], "exclude_matches": ["*://mail.google.com/*"], "css": ["font.css"] }] This cannot be fixed even adopting the strategy advised here by replacing exclude_matches with exclude_globs . I know this bug

Chrome extension making mouse click with extension

时光怂恿深爱的人放手 提交于 2019-12-25 04:15:39
问题 Is it possible to make particular elements act as it was clicked on them by calling another function? For example I am trying to make an extension which will automatically clicks a button once I click on the extension. Is it possible to achieve this and if so can somebody point me to the direction of how to do it? 回答1: I think this can be done by the content script. I would add a listener to the extension icon click in the background page. After the callback is triggered, I would inject a

What message is generated by the chrome “permissions” property in an extension manifest?

故事扮演 提交于 2019-12-25 04:12:13
问题 Given a manifest containing the following "permissions" array, what message can a user expect to see when installing an extension with this permission in Chrome? { "name": "My extension", ... "permissions": [ "http://www.google.com/" ], ... } 回答1: Visit chrome://extensions , search for your extension and click on "Details" ("Permissions" in Chrome 40 and earlier). That will display a screen with the permission warnings that you'd see if the user installs the extension. You can also use the

How to know when dragging a tab has finished?

荒凉一梦 提交于 2019-12-25 03:53:27
问题 I am building a Chrome extension that moves my pinned tabs to the active window: http://screencast.com/t/bRroTVda It works great, with one exception: When switching to another Chrome window by clicking on a tab in that window, I can't use chrome.tabs.move to move my pinned tabs to the newly activated window. runtime.lastError in the callback says Tabs cannot be edited right now (user may be dragging a tab) My problem now is: There seems to be no event that I can subscribe to that is raised

Inject an SVG image using a content script

筅森魡賤 提交于 2019-12-25 03:50:07
问题 I have a chrome extension that injects JavaScript into a page using a content script and I want that script to add an SVG image to the page. Here's the code I'm using: var url = chrome.extension.getURL('infotip.svg'); $('#elementId').append('<embed src="' + url + '" type="image/svg+xml" style="display: block; float: right;" />'); When I inspect the resulting DOM, the URL to the SVG file is set correctly (I can open it in a new tab from element inspector & it works) but in the actual page,

Chrome not allowing Ajax request to permitted domains

会有一股神秘感。 提交于 2019-12-25 03:33:03
问题 I'm creating my first Chrome extension, a relatively simple one with some ajax calls. My manifest is pretty simple: { "name": "Read It Now", "version": "0.12", "description": "Read it now.", "permissions": [ "https://readitlaterlist.com" ], "app": { "launch": { "local_path": "index.html" } } } I'm then using jQuery to fetch some simple data from a URL like: https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz However, Chrome still rejects it: