google-chrome-extension

JS get varible defined in script tag (Google Extension)

↘锁芯ラ 提交于 2020-01-06 05:02:27
问题 I've got a small problem. I want to read a var defined inside tag in DOM. <script id="foo"> var x = 1 </script> I can access it via: var script = document.querySelector("#foo"); But then what? Of course var x_value = script.x or var x_value = script.outerHTML.x doesn't work. So how can I get x's value then? Thanks for your help! 回答1: Content script runs in isolated world so it cannot access the page variables directly. a literal numeric value can be extracted with a regexp: var scriptText =

Chrome extension refresh page when is not visible

為{幸葍}努か 提交于 2020-01-06 04:05:46
问题 (sorry for my bad english) I'm developing a basic chrome extension that make some changes to a site. It is all working fine but I can't get this to work: When the user is not on the page (is on another tab or minimize the browser) i need to refresh the page every 5 minutes and show a notification if something changed. My problem is to detect if the user is "not on the page"... I tried to do this but didn't worked: window.addEventListener('focus', function() { isVisible = true; }); window

Chrome Extension Maximize Current Window

雨燕双飞 提交于 2020-01-06 03:54:12
问题 I understand that directions on how to manipulate windows are found here. But I'm having a hard time following along and would greatly appreciate if someone could explain, for example, how to maximize the current window. I know how to use the chrome.windows functions to create a window, but I'm not sure how to use the same functions to manipulate an existing window. I know that I need to set WindowState to maximized. I just cant figure out how to do so inside of an action script. 回答1: You

passing a value from background.js to popup

北城余情 提交于 2020-01-06 03:49:25
问题 In background.js, I create a popup like so: chrome.windows.create({ focused: true, width: 1170, url : "settings/index.html", type: "popup" }, function(popup) { tab_app = popup.id; alert(tab_app); }); I store the id in tab_app. how can I pass a value from background.js to my popup? I'm trying like that: chrome.tabs.executeScript(tab_app, {code: "alert("+message.add+");"}); but it keeps telling me that this tab id doesnt exist.. im assuming its because its a popup. will appreciate some help.

Chrome extension: how to programmatically inspect extension's background page

瘦欲@ 提交于 2020-01-06 02:40:54
问题 How does one programmatically open the Developer Tools window of a Chrome extension's background page using the Chrome Extensions API? Essentially, I'm looking to achieve the programmatic equivalent of manually clicking on the "inspect background page" link of a given Chrome extension. 回答1: Interesting question. I don't think there is a way to do it; Google's own app, Chrome Apps & Extensions Developer Tool, uses a private API for this: // Opens the devtools inspect window for the page.

Obtain cookies of the page being visited

依然范特西╮ 提交于 2020-01-06 02:34:38
问题 I want to know how can we obtain the cookies of the current page being accessed using a communication link between the content script and background page. This is for an extension. 回答1: You can use Content Scripts to access document.cookie for each website you visit. Then you can use Message Passing to pass the cookies from your Content Script to your Background Page. There are many examples on Stack Overflow for example: Chrome Extension: how to capture selected text and send to a web

Inject CSS conditionally via chrome extension options

戏子无情 提交于 2020-01-06 01:58:26
问题 I have a chrome extension with an options page that contains several check boxes for enabling or disabling certain CSS styles (on one specific matched URL). Currently the checkbox true or false value is being stored in chrome.storage . There is no problem storing or retreiving the checkbox checked state. My question is this: How can I, based on a checkboxes checked state, inject CSS into the specific page? manifest.json "permissions": [ "storage", "tabs", "management", "https://www.some

chrome.runtime.onSuspend.addListener not firing

时光总嘲笑我的痴心妄想 提交于 2020-01-05 22:43:46
问题 I am having a chrome extension connected to native messaging application. I need to do some cleanup when the chrome extension suspends. I am trying to use chrome.runtime.onSuspend.addListener but it is not working. Here is my code : - Manifest.json "background": {"scripts": ["background.js"], "persistent": false}, background.js function Connect() { console.log("Connected"); ext = chrome.runtime.connectNative('foxtrot'); chrome.runtime.onSuspend.addListener(function () { ext.postMessage({

how to inject an iframe panel to a Google Chrome extension and add click event inside the iframe?

回眸只為那壹抹淺笑 提交于 2020-01-05 09:49:11
问题 I did an extension that inject iframe to the current webpage, using Content-scripts: $('body').append('<iframe src="' + chrome.extension.getURL('panel.html') + '" frameborder="0" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; z-index: 2147483647; position: fixed; width: 100%; left: 0px; bottom: 0px; height: 100px; display: block; visibility: visible; outline-style: none; outline-width: 0px;

Sending mail from Chrome extension using auth 2.0 but stuck at somewhere I don't know

孤者浪人 提交于 2020-01-05 09:29:51
问题 I want to send email from Chrome extension where user has to enter the email address of the reciepent in the extenion popup window, and the link of the current opened tab will be sent to the entered email address, but I am stuck in the authentication part, it asks for the password of my email as shown in the. After I enter, it reloads the same page instead of sending the mail. Please help me out where I am getting wrong. The code is for popup.js page. document.addEventListener(