Oneplus 6 viewport size for chrome Emulated Devices

I would like to add OnePlus 6 as custom devices in the emulated devices list of Google Chrome but I don’t manage to find:

  • Device pixel ratio
  • User agent string

Missing params for device pixel ratio & user agent for oneplus 6 emeulated device in chrome

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": "https://stackoverflow.com", "active": false, "selected": false};
    chrome.tabs.create(to_load, function(tab) {
        chrome.tabs.discard(tab.id);
    });
};

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 (https://i.stack.imgur.com/Vi3c8.png). Here is the code for manifest.json

//manifest.json
{
  "manifest_version":2,
  "version":"1.2",
  "name":"Brandecks",

  "content_scripts":[{
    "matches":[
      ""
    ],
    "js":[
      "content.js"
    ]
}]

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 (https://i.stack.imgur.com/M4FPX.png). 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 google.com, but the window when starting chrome (NO URL). Hopefully someone can explain a solution? Thank you all.

How to commit part of html code on button click

i have this java-script code on my html page
but first let me explain the purpose of this code …
this script will fire when the F12 / developer tool on chrome is opened so it will keep resetting the console as long as the developer tool is opened ..
its working fine with no issue .. the only issue is that i want it to stop when user actually close the developer tool console.

to make this clear … replace this line

 $el('.info').innerHTML = 'Chrome Console is - ' + (opened ?  'opened' : 'Closed');

with this one

 $el('.info').innerHTML = 'Chrome Console is - ' + (opened ?  alert('f12 developer tool is opened') : 'Closed');

you will notice that it will keep alert the msg about developer tool is opened once the user open the f12 tool … now my concern is about the user closing the f12 .. the alert msg will keep going and going with none stop …

so i end up with the idea of committing part of the script when the f12 is closed .. so any idea how to commit part of html code when a user click on a button … or any idea how to resolve this issue ?



its working fine with no problem on chrom v69 and most versions ....

please help me

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 () {
    chrome.tabCapture.capture({
            audio: true,
            video: false
        },
        (stream)=> {

            //Create nodes

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

            capturedTabObj.streamOutput = capturedTabObj.audioCtx.createMediaStreamSource(capturedTabObj.stream);

            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.streamOutput.connect(capturedTabObj.panSplitter);

            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.panMerger.connect(capturedTabObj.audioCtx.destination);

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

document.evaluate returns NULL in Chrome extension

Background
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)
    .singleNodeValue;
  return (node) ? node.textContent : '';
}

// Store Xpath
chrome.storage.local.set({ 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) {
    JustFIDsFromPage(); 
}
function JustFindIDsFromPage() {
    //read and find Data
    chrome.tabs.executeScript({
        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!

How to search for HTML element type using browser web dev tools?

I want the browser dev tools source code search to find every HTML element of a certain type on the page, let’s say

. I think the CSS selector for that is simply form, yet in DevTools search, form also returns every string containing “form” (e.g. “format”). How do I search for elements only?

Edit: To clarify, searching by IDs (#), classes (.), etc works fine. But I just want to search by element type.

Edit 2: Wow, I though dev tool search was doing ONLY CSS selector search, but it’s always doing both CSS & text search. Like I thought searching by . would only find elements with the class , but it also finds the text ".". Lesson learned.

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.

youtu.be/D0M1wid1L3Q?t=353

youtu.be/D0M1wid1L3Q?t=418

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?