google-chrome-extension

Chrome Extension - Dynamic Right-Click Menu

烈酒焚心 提交于 2020-03-17 03:50:25
问题 I am trying to create an option in the right-click menu that is dynamic based on the user's action. If the user selects some text, then right-clicks, the option will say "Display It". If the user right-clicks without selecting some text, the option will say "Select Some Text First" and be grayed out. I am wondering how do I achieve this? I currently have it so that the option will appear only when the user has selected some text. I am unsure how to modify it to meet my second requirements.

Chrome Extension to show a toggle to enable/disable extension

≯℡__Kan透↙ 提交于 2020-03-16 09:17:05
问题 Here is my manifest { "name": "my-extension", "version": "0.0.9", "manifest_version": 2, "icons": { "16": "img/icon16.png", }, "browser_action": { "default_icon": "img/icon16.png", "default_popup": "html/popup.html" }, "web_accessible_resources": [ "data/links.json" ], "content_scripts": [...], "background": { "scripts": [ "js/background.js" ] }, "permissions": [ "tabs", ] } I'd like a toggle to be in html/popup.html so that when the user clicks it, I can store some boolean to know if my

Chrome Extension to show a toggle to enable/disable extension

梦想的初衷 提交于 2020-03-16 09:15:37
问题 Here is my manifest { "name": "my-extension", "version": "0.0.9", "manifest_version": 2, "icons": { "16": "img/icon16.png", }, "browser_action": { "default_icon": "img/icon16.png", "default_popup": "html/popup.html" }, "web_accessible_resources": [ "data/links.json" ], "content_scripts": [...], "background": { "scripts": [ "js/background.js" ] }, "permissions": [ "tabs", ] } I'd like a toggle to be in html/popup.html so that when the user clicks it, I can store some boolean to know if my

How can I enable my chrome extension in incognito mode?

邮差的信 提交于 2020-03-07 07:08:05
问题 I created an extension for Google Chrome and would like to know if it is possible for my extension to be enabled in incognito mode. Ex: chrome.extension ...... allowedIncognitoAccess = true 回答1: It's not possible to automatically activate incognito mode for Chrome extensions. Instead of letting the user figure out where the option can be found, just instruct the user to put a check on the checkbox at the extension. To detect whether incognito is enabled, use the chrome.extension

Chrome Extension: using document.querySelector in background script

帅比萌擦擦* 提交于 2020-03-05 07:37:04
问题 I'm trying to set a variable equal to the favicon url of the current page. Are you not able to do this in the background script? How else could I get the current page's favicon url that the user is on? background.js var currentFaviconURL = document.querySelector("link[rel*='shortcut icon']").href; console.log(currentFaviconURL); console Error in response to tabs.query: TypeError: Cannot read property 'href' of null 回答1: For reading and manipulating DOM, you must use Content Scripts. https:/

Chrome Extension: using document.querySelector in background script

跟風遠走 提交于 2020-03-05 07:36:08
问题 I'm trying to set a variable equal to the favicon url of the current page. Are you not able to do this in the background script? How else could I get the current page's favicon url that the user is on? background.js var currentFaviconURL = document.querySelector("link[rel*='shortcut icon']").href; console.log(currentFaviconURL); console Error in response to tabs.query: TypeError: Cannot read property 'href' of null 回答1: For reading and manipulating DOM, you must use Content Scripts. https:/

Import Typescript file in Javascript

一个人想着一个人 提交于 2020-03-05 04:05:19
问题 I'm making a Chrome extension and I'm trying to import a Typescript file in Javascript. Both files are next to each others. I'm importing it this way: import { ApiParsing } from './ApiParsing.ts'; When I'm using the extension I have the following error: Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec. 回答1: TypeScript cannot be executed from a browser / node.js environment directly.

Log javascript errors in Chrome?

白昼怎懂夜的黑 提交于 2020-03-04 12:35:43
问题 I'm trying to create a Chrome extension that will log all the javascript errors that show up in the Javascript console and then send that to me. I've been trying the chrome.debugger.onEvent.addListener and the window.onerror and nothing seems to be running. Can someone point me in the right direction? These are not syntax errors by the way. They are network errors. The page might return an error and I want to log that. 回答1: I found Evaluating network performance in one of my researches and it

Log javascript errors in Chrome?

醉酒当歌 提交于 2020-03-04 12:35:15
问题 I'm trying to create a Chrome extension that will log all the javascript errors that show up in the Javascript console and then send that to me. I've been trying the chrome.debugger.onEvent.addListener and the window.onerror and nothing seems to be running. Can someone point me in the right direction? These are not syntax errors by the way. They are network errors. The page might return an error and I want to log that. 回答1: I found Evaluating network performance in one of my researches and it

How to pass nodelist object to background script?

自古美人都是妖i 提交于 2020-03-03 07:46:29
问题 I want to get all titles from reddit, and pass it to backgroundScript.js . It shows all URLs in the console of the page but for some reason it shows me this message on background page: My code: manifest.json : { "manifest_version": 2, "name": "Testing stuff", "description": "This extension is for testing purposes", "version": "1.0", "background": { "scripts": [ "backgroundScript.js" ] }, "content_scripts": [ { "exclude_matches": [ "*://*.reddit.com/r/*/ comments /*" ], "js": [ "contentScript