google-chrome-extension

How to access localStorage in extension background page?

好久不见. 提交于 2020-01-15 12:20:40
问题 I have a chrome extension that sets a string value in JavaScript localStorage in a content script. I have tested that it is being set by grabbing it and displaying it. While on the same page after it has loaded I can still access the stored string in the javascript console. If I go to any other tabs js console or when I try to access it in my other extensions background page(After the browser action has been clicked) it is returning null. extension 1 contentscript.js embeded.addEventListener

Binding extension content scripts to Chrome's start page?

牧云@^-^@ 提交于 2020-01-15 12:15:06
问题 Is there any way to bind a content script to Chrome's start page? I tried setting matches to "*" , but it doesn't even run. With "*://*/*" it does not bind. 回答1: No, you cannot*. Technically, the start page is chrome://newtab/ , and Chrome Extensions cannot access chrome:// pages for security reasons, not even with the widest "<all_urls>" permission. Your only hope is to make your own New Tab page, though it would be hard to replicate all of the default functionality (e.g. thumbnails of top

Binding extension content scripts to Chrome's start page?

…衆ロ難τιáo~ 提交于 2020-01-15 12:15:05
问题 Is there any way to bind a content script to Chrome's start page? I tried setting matches to "*" , but it doesn't even run. With "*://*/*" it does not bind. 回答1: No, you cannot*. Technically, the start page is chrome://newtab/ , and Chrome Extensions cannot access chrome:// pages for security reasons, not even with the widest "<all_urls>" permission. Your only hope is to make your own New Tab page, though it would be hard to replicate all of the default functionality (e.g. thumbnails of top

How to include a link in a Webkit notification?

杀马特。学长 韩版系。学妹 提交于 2020-01-15 12:13:11
问题 I am creating a Chrome extension and I am using the Webkit notifications API. I need to show a link in the notification, but the problem is that now Webkit HTML notifications are deprecated, so I only can use notifications with a simple message. I mean, one year ago I could have created a Wbkit HTML notification and include the "a" element, but now I can't. Is there a way to show a link in a Webkit notification? Thanks. 回答1: To make a webkit notification a link, do this (I'm using jQuery for

How to expose a function from a Chrome devtools extension “before” page loads?

纵饮孤独 提交于 2020-01-15 11:06:45
问题 I am working on a Chrome devtools extension that exposes a function ( extensionEntryPoint ) to the inspected page. The problem is that extensionEntryPoint is not available at the initial scripts in the inspected page loads and runs. I can use it from window.onload , but that is too late. Here's my code: manifest.json : { "name": "Extension", "version": "1", "manifest_version": 2, "permissions": [ "activeTab" ], "web_accessible_resources": ["api.js"], "content_scripts": [ { "matches": ["<all

change color of element Chrome extension

ⅰ亾dé卋堺 提交于 2020-01-15 07:07:27
问题 I have created a simple Jquery script as an chrome extension that are suppose to change the font color of a class. the script is working fine if I use it directly in the console. but if I run it as an extension It wont trigger when the value is higher than one. Any suggestion of what could be the problem? Script.js (function(){ $("#ID-layout-1435216276773-counterValue").each(function() { var el = $(this); var value = parseFloat(el.text()); if (value > 1) { el .css("font-weight", "bold") .css(

CustomEvent.detail “tainted”?

淺唱寂寞╮ 提交于 2020-01-15 07:02:19
问题 I'm developing a Chrome extension to add convenience to a website. I have access to the page's DOM, but I also need to interact with the "first-party" JS on that page, which I cannot do from my extension. I can inject arbitrary tags into the page (most notably also <script> tags), but since escaping strings like { html: '<div onclick="doSomething(this, \'someName\')"></div>' } is a real pain, I'd like to keep the injected code at an absolute minimum. I tried injecting event listeners into the

Chrome Extension how to write file in Extension Directory

梦想的初衷 提交于 2020-01-15 05:27:06
问题 This is just a quick question regarding chrome extension file writing. Is it possible to write a file in the chrome extension directory? (by that I mean write a file in the same folder where I have my manifest file and other scripts) So far I have found out I can read a file in the directory via XMLHttpRequest but I have found no answer as to whether or not writing a file there is possible. Thus far I have found out I could write files in the browser via the HTML5 file system API but to my

How can Chrome extensions basically cURL other pages?

家住魔仙堡 提交于 2020-01-15 03:09:09
问题 I'm thinking about writing a Chrome extension that will need to, on a certain dynamic page of a certain site, grab a few links and analyze the contents of the linked pages. I actually don't know much about writing browser extensions, so I wanted to see if it was doable before I committed myself to learning how. I do know that extensions typically execute Javascript but I am unaware of how to get that sort of result with Javascript. 回答1: Use jquery ajax to fetch the content of other pages. 回答2

Google Chrome access search engine settings from extension

杀马特。学长 韩版系。学妹 提交于 2020-01-14 22:47:15
问题 I need access to search engines settings from Chrome extension to populate context menu with search engines list. Extension operate as follows: User select text, opens context menu with submenu "Search {selection} by ..." and get list of engines, click needed engine and go to relevant search url 回答1: Your best option is going to manually build an extensive list of search engines that are displayed to the user. There is no pragmatic method of collecting currently installed search engines. 来源: