How can I open a tab without loading it in a Google Chrome extension?

The only thing I could think of was using chrome.tabs.discard, and below is my current code:

var test_button= document.getElementById('test_button');
test_button.onclick = function(element) {
    var to_load = {"url": "", "active": false, "selected": false};
    chrome.tabs.create(to_load, function(tab) {

However, rather than preventing this page from loading, calling chrome.tabs.discard before it’s loaded results in Chrome replacing it with about:blank.

The only “solution” I found was to wait for the tab to load, but waiting for it to load before unloading it defeats the purpose, especially if I’m opening a large amount of tabs at once.

Any help would be appreciated.

Chrome Addon: Execution On Chrome Home Screen?

So I literally am just learning how to make addons on chrome, and I’m having a hard time getting a content script (javascript) to execute on the chrome home screen ( Here is the code for manifest.json



I’m trying to accomplish this so I can use a javascript to remove html elements on that specific page. The content script I have linked to the manifest does exactly that for me, although it doesn’t want to execute on the home screen. Here is what it would look like, it’s just getting rid of the elements below the search bar ( I’m assuming the problem is somewhere around “matches”, although I’m not sure. Important note: when I refer to “home screen” I am not referring to, but the window when starting chrome (NO URL). Hopefully someone can explain a solution? Thank you all.

Chrome extension: Trying to build an audio pan using Web Audio API and chrome.tabCapture.capture

I am trying to mute the right speaker in order to simulate full pan, but can still hear a low volume signal through it, and can’t figure out why.

Here is the simplified code (bg.js):

    var capturedTabObj = {};

    chrome.browserAction.onClicked.addListener(function () {
            audio: true,
            video: false
        (stream)=> {

            //Create nodes

            capturedTabObj.audioCtx = new AudioContext();
   = stream;

            capturedTabObj.streamOutput = capturedTabObj.audioCtx.createMediaStreamSource(;

            capturedTabObj.panSplitter = capturedTabObj.audioCtx.createChannelSplitter(2);
            capturedTabObj.leftGain = capturedTabObj.audioCtx.createGain();
            capturedTabObj.rightGain = capturedTabObj.audioCtx.createGain();
            capturedTabObj.panMerger = capturedTabObj.audioCtx.createChannelMerger(2);

            //Connect nodes


            capturedTabObj.panSplitter.connect(capturedTabObj.leftGain, 0);
            capturedTabObj.panSplitter.connect(capturedTabObj.rightGain, 1);
            capturedTabObj.leftGain.connect(capturedTabObj.panMerger, 0, 0);
            capturedTabObj.rightGain.connect(capturedTabObj.panMerger, 0, 1);

            capturedTabObj.leftGain.gain.setValueAtTime(1, capturedTabObj.audioCtx.currentTime);
            capturedTabObj.rightGain.gain.setValueAtTime(0, capturedTabObj.audioCtx.currentTime);

document.evaluate returns NULL in Chrome extension

Hi, I am building a chrome extension which allow user to get the document location (DOM element) using context menu via Xpath.
This Xpath will store in the browser’s local storage.
Text Value will retrieve

Scenario 1
When User select the element via context menu; extension will store the Xpath from that element and store it in the local storage.
Text Value will be retrieve using document.evaluate and Xpath. This will be used as a request parameter (ajax request).
[This scenario is working]

Scenario 2
When user reload the page or navigate to another page I want to send the request without using the context menu interaction. Extension will retrieve the Xpath from Local Storage and try to get the Text Value using document.evaluate. This result a NULL value.

I have implemented this code under content_scripts.
But [This scenario is NOT working]

Some Important Code Snippets

// Get Text Value using xpath
function getValueByXpath(path) {
  const node = document
    .evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null)
  return (node) ? node.textContent : '';

// Store Xpath{ candidateEmailXpath: xpath });

Is it possible to read xpath after page reload?
How do I try document ready method here? (if possible)

How can i excute script New page in chrome extension?

I make chrome extension.
this program read now page and anlysis it, go to next page.

I already made read and goto next page. but there a problem.
read now page and move next page is perfect. but next page, read function isn’t work.

I click read button on first page, read it. but move next and read, not work.

i see callback function get undefined data.

below is my code.

function matching(user) {
function JustFindIDsFromPage() {
    //read and find Data
        code: "var ids = [];var names = document.querySelector('.gallery').children;for(var i=0;i

I guess this.

chrome.tabs.executeScript just excute on 'first' open page.

I don't know what is real. please help me!

implement Auth0 into chrome extension with one time use tokens

Im making a chrome extension where I want to create a security method for my chrome extension to stop it from getting shared without me in the process

I have an idea to generate a token somewhere (usually some backend, maybe server of the website that gets user registrations/payments my website which I am building with worpress), send token via email, get email+token in extension, make request to webserver to verify that they’re valid. This seems like a typical auth flow except the password is now the token, which is generated instead of set by the user. In other news, I have more ideas (Extension-side prng with shared seed, can check to see if token is within X generations for eg.)

I want to be able to sell tokens on my website which only allow one use to prevent the token from being shared.

I tried to setup the Auth0 for the chrome extension but I keep getting errors and the process doesnt lead to how I would want done.

is a great example of what I want to be able to do. Can anyone help me doing this? I am building my website in wordpress not hard coding it so Im not sure on How to do this exacly

If anyone can point me in a direction of what I am supposed to do or maybe provide some code that could help me?

I really appreciate the help Thank you <3

ESlint: How to ignore Parsing error: Invalid regular expression flag

I’m creating a Chrome extension. I want to write a code that matches strings including n like this:

var s = "anb";
console.log(s.match(/a.*b/s)); // prints non-null

I used the s flag because it worked on Chrome 67.0.3396.99. However, this flag is not defined in standard Javascript, so ESlint says

2:22  error  Parsing error: Invalid regular expression flag

Is there any way to ignore this? I tried // eslint-disable-line no-invalid-regexp in my code and

"no-invalid-regexp": ["error", { "allowConstructorFlags": ["s"] }],

in my .eslintrc.json but neither worked (it seems it works only for RegExp constructors and not // regexp).

I tried // eslint-disable-line and /* eslint-disable */ but neither worked, too.

In The ESlint document,

Note: Comments that disable warnings for a portion of a file tell ESLint not to report rule violations for the disabled code. ESLint still parses the entire file, however, so disabled code still needs to be syntactically valid JavaScript.

So this s flag is considered as invalid Javascript. Is it really impossible to ignore this error? Or can this be ignored by plugins or something?

How can i write some text by Chrome extension?

I create some crawler analysis program by chrome extenstion.
I already make crawl and analysis target, but i don’t know how to output for file.

my program watch many page and move urls, i need ‘create’ txt file and ‘write’, ‘add’ functions.
I try to search, i just found image downloads…
I think google must support it. but i can’t found.

someone know API or example?
please help me!

Add custom toolbar button on selecting mail from mail list

I am adding toolbar button to the gmail view. Using gmail.js I have written chrome extension. After adding this extension, the toolbar button is appearing in mail. following is the code structure in main.js file

var main = function() {
gmail = new Gmail();
// add toolbar'', function()) }

calling this main function on page loading,

function refresh(f) {
if( (/in/.test(document.readyState)) || (typeof Gmail === undefined) ) {
setTimeout('refresh(' + f + ')', 10);
} else {

my requirement is to show the toolbar button only when at least 1 mail is selected, like other toolbar buttons. How to catch the event of mail selection, so that I can call the add_toolbar_button() only when at least one mail is selected from visible label.
As, I am calling this main() on page loading, this toolbar button is appearing right after we are opening gmail ui.

How chrome extension monitor window minimize event and get activated tab info in that window

I want to write an extension which will run some func when the window is maximized/minimized, and the func needs tab info before minimized as well. I tried, however, it only works when there are multiple windows. Is there any way or JS scripts that can detect whether a window is minimized?