google-chrome-extension

Open two new tabs from popup.html and popup.js

南笙酒味 提交于 2021-01-29 15:49:54
问题 I have some code, which lets user check checkboxes and on submit opens urls associted with checkboxes in new tabs. In case both checkboxes are checked two tabs become opened. It works like expected and looks like: document.getElementById('cbx').addEventListener( 'submit', function checkForm(event) { //Prevents default action that would normally happen onsubmit event.preventDefault(); //Define the form element var form = document.getElementById("cbx"); if (form.cb1.checked) { window.open('http

Securing chrome extension API Calls with tokens

岁酱吖の 提交于 2021-01-29 15:06:15
问题 I'm trying to secure API calls from my chrome extension to my website hosted on AWS. The SO posts I've so far were quite dated & not effective ways. The most recent & best tutorial I've found so far is from Very Good Software where it requires for user's google OAuth access token via: Background.js: chrome.identity.getAuthToken({ 'interactive': true }, function(token) { if (token){alert('token is ' + token)} else{alert('token not present')} }); manifest.json { "manifest_version": 2, "name":

weird Uncaught TypeError: Cannot set property 'onclick' of null

泄露秘密 提交于 2021-01-29 15:01:05
问题 I'm currently learning to develop a google chrome extension. I'm trying to get a button to list all of the span elements in the console for now. However, I can't seem to set the function of the button and keep getting a weird Uncaught TypeError: Cannot set property 'onclick' of null error. index.html: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Simple Greeting Dashboard</title> <link rel="stylesheet" href="style.css" /> </head> <body> <button id="main-switch">Update prices:<

How and where do I store user preferences with the Chrome.storage API in a chrome extension?

一世执手 提交于 2021-01-29 14:51:14
问题 I am trying to store the value of a checkbox in the popup.html file. I have these two functions in my popup.js file: function storeUserPrefs() { var isHighlighting = false; var highlightedCheckBoxVal = $("#highlightedCheckbox").is(":checked"); chrome.storage.sync.set({isHighlighting: highlightedCheckBoxVal}, function() { console.log("saved " + isHighlighting + "as " + highlightedCheckBoxVal); }) } function getUserPrefs() { chrome.storage.sync.get(['isHighlighting'], function(result) { console

How to get cpu usage of current tab from chrome

天涯浪子 提交于 2021-01-29 12:57:28
问题 I am using the chrome extension api chrome.processes and chrome.tabs and have been trying to get the cpu usage of current tab only. I looked at the chromium example code for reference but the purpose of its code is to display all information of all the processes on chrome but i only need the current tab"s information. this is my code var tid; var cpu; chrome.tabs.get(tabid, function(tabid) { tid = tabid.id; }); chrome.processes.onUpdatedWithMemory.addListener( function(processes) { for (pid

Unchecked runtime.lastError: Cannot access contents of url. But I dont need to access content of that URL

狂风中的少年 提交于 2021-01-29 12:34:51
问题 I am making a Chrome Extension. Below, I have pasted the manifest file for that. Manifest File { "manifest_version": 2, "name": "abc", "version": "0.1", "author": "def", "description": "", "permissions": [ "tabs", "storage", "webNavigation", "*://www.youtube.com/*" ], "content_scripts": [{ "matches": [ "*://www.youtube.com/*" ], "js": [ "content.js" ], "css": ["style.css"], "run_at": "document_end" }], "background": { "page": "background.html" }, "browser_action": { "default_popup": "index

onclick or inline script isn't working in extension

隐身守侯 提交于 2021-01-29 10:47:30
问题 This seems to be the easiest thing to do, but it's just not working. In a normal browser the .html and .js files works perfectly, but in the Chrome/Firefox extension the onClick function is not performing what it's supposed to do. .js file: function hellYeah(text) { document.getElementById("text-holder").innerHTML = text; } .html file: <!doctype html> <html> <head> <title> Getting Started Extension's Popup </title> <script src="popup.js"></script> </head> <body> <div id="text-holder"> ha <

unknown error: failed to wait for extension background page to load: chrome-extension error loading an extension to Chrome Headless using Selenium

十年热恋 提交于 2021-01-29 10:31:12
问题 I try to run chromedriver via selenium in headless mode. IMPORTANT The code runs perfectly fine if I eliminate the following code lines (but is not headless): chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-dev-shm-usage') This is the error I get when I try to implement the headless argument: Traceback (most recent call last): File "camel_amazon_scraper.py", line 83, in <module> executable_path=executable_path) File

Can Chrome Extensions steal OAuth tokens from redirect-uri?

蹲街弑〆低调 提交于 2021-01-29 09:48:03
问题 I'm working on auth between a Chrome Extension, Google Cloud Platform, and trying to send the id_token JWT to an AWS server to retrieve user data (and/or establish a session?). My question is this -- how can I prevent chrome extensions with tabs permissions from reading the GET request or the redirected URI which has the fully-validated user JWT? The JWT confirms that a user is who they are, but how do I know my Chrome Extension is the one making the request to my backend? I have a few ideas:

JS Function Not Defined Chrome Extension Popup.js

纵然是瞬间 提交于 2021-01-29 09:42:24
问题 I am trying to add this button On Codepen to my chrome extension, my HTML and CSS work perfectly fine. The JS is popup.js and is on the same level as the rest of the code, but it doesn't seem to be linked to the popup.html. Manifest is in the image . I did convert the SCSS to CSS using an online converter. I need help linking the js to popup.html so the button works as it does in Codepen. Html, CSS & JS: $('button.cooldown').click(function(){ var btn = $(this); btn.prop('disabled', true);