google-chrome-extension,timeout,google-chrome-devtools , only works with timeout only works with timeout


Tag: google-chrome-extension,timeout,google-chrome-devtools

I'm writing a chrome extension that is supposed to show a page action icon whenever a PDF is loaded. To this end, I'm checking the content type, and if it equals application/pdf, I To my surprise, however, this

  function(details) { 
    if (details.tabId >= 0) { 
      var header = getContentTypeFromHeaders(
      global.tabToMimeType[details.tabId] = 
        header && header.value.split(';', 1)[0];
      if (global.tabToMimeType[details.tabId] === 'application/pdf') {;
    urls: ['*://*/*.pdf'],
    types: ['main_frame']

doesn't work. I can see the icon flashing up sometimes, but it's never persistent. If instead I replace;


setTimeout(function() {;
}, 100);

it all comes out nicely. What is the explanation for this? Is there any more systematic way than waiting for 100 milliseconds?


I believe the problem is that you try to show too early, before the navigation is processed by a tab.

So your icon shows up, THEN page transitions and the icon is wiped.

Try moving your logic to onResponseStarted or even to onCompleted.

Since even that is not enough, and it's hard to tie a webRequest event to a tabs/webNavigation event, you can either proceed with your approach or try and find another method of detecting PDFs with tabs/webNavigation API.

This quote from webNavigation docs shows what I mean:

In general, the webNavigation events are closely related to the navigation state that is displayed in the UI, while the webRequest events correspond to the state of the network stack which is generally opaque to the user.

So webRequest events are not tied to the tab transition and can't be reliably used for showing a page action.


Looking for tool that prevent script to become unresponsive [on hold]

For a side project I need to generate a lot of data from a WebGL Application. This Web App is mostly a personal tool and I really don't care if my browser become unresponsive (I mean, I know it will). Does someone know a browser/tool/plugin that could allow me to...

How to tell if a page is loaded as a popup or in a separate tab in chrome extension

My Chrome extension has a page that is seen in a popup or as a separate tab. When it seen as a separate tab, I need to show a small button at the corner of the page. But I couldn't find a way to detect when a page is loaded...

Timeout accesing SQL Azure on Basic/Standard tier - works fine on Web tier

I am upgrading a legacy azure site to use one of the current SQL azure tiers from the old web tier. The site works fine on the website and locally but when I switch from web to basic or standard I get timeout errors. The code that is timing out...

PHP script runs much longer than max_execution_time?

PHP is running as an Apache module. The script start with a: ini_set('max_execution_time', 300); What it does is basically connecting to a database, doing a big SELECTquery and looping through the results, writing them to a file and echoing a "result ok" after each write with explicit flush(); There is...

How does an unpublished extension get weekly users?

This is weird. I have an extension that is not available through the webstore because it's marked as private and is still pending review. However, I see the weekly users count increasing. When the counter was at 1, I thought it was somehow tracking my own usage of the locally...

Function timeouts in C and thread

Hello everyone i have a question about timeouts in c so i ask you guys. So i'm making a server application in C that uses POSIX threads to accept multiple simpultenious connections but implementing timeouts was harder than i expected as i read the message (HTTP requests) in parts first...

Passing a response callback via promise between background and content script? [duplicate]

This question already has an answer here: Chrome Extension Message passing: response not sent 2 answers I'm trying to inject an html template into the DOM of a webpage via a content script. I prefer to keep the html files in their own folder within the extension so that...

Making a counter with angular and timout

hey i'm trying to build a simple counter that shows in my html. it kind of works but it doesn't listen to the timeout and gives a bunch of errors. This is the error i'm getting TypeError: fn is not a function This is the javascript function and object: $scope.funFacts...

Is it possible to use (or include) node.js framework in a Google Chrome Extension?

I don't want to create a chrome extension ONLY using node.js. I know chrome extensions use HTML, CSS and JavaScript. But I want to make a chat application as a chrome extension. I found that using MEAN stack along with for a chat application is the latest way and...

Using Youtube's Data API

I cannot figure out how to use Youtube's API V3, with Chrome's identity extension API. Is there a tutorial somewhere? I would like to start by rating a video.

Chrome Extension Script not Working

I am extremely new to creating extensions for chrome, and right now I'm just trying to mess around and create a simple canvas that you can open up and draw on. When I load popup.html as a normal webpage everything seems to work just fine, but when I open the...

How to force loading images for the webpages installed “lazy load” without scrolling?

I implement a Chrome extension. The extension needs to get all images URLs of webpages. However, some webpages have "lazy load" plug-in. My question is if it is possible that I can still get URLs without required manually scrolling down?

Running Apps Script from Chrome extension requires authorization

I'm trying to execute a Google Apps Script from an event on my Chrome extension. While it works great, when ran for the first time by a new user, the apps script requires for the user to give it authorization before it can execute. The problem is when running the...

detect requests calls in a url similar to network in chrome dev tools

I don't know if what I am looking for is possible, I want JS, or any other programming method solution to detect the requests calls for a given url page, something similar to chrome dev tools There is a site that displays videos, I would like to access through the...

Javascript reruning timeout after being cleared

I have a function with parameters that do some operations on these parameters then send them to itself again with certain timeout Now i want to clear this timeout but at some point i want to recall that timeout that was cleared with its current parameters anyway to do this...

Host my own chrome extension in my website

I have developed one chrome extension and i want to use it on some windows pc's all over the world (of course the owners know me and my work) but i dont want to upload it on WEBSTORE since its only for something we use for ourselfs. Could i host...

Can I fire up a Chrome extension API from code?

Is it possible to launch a Google Chrome extension within a website? E.g run some javascript that will launch the extensions UI? I'm building a web-app that will allow users to take screenshots of their desktop and edit them. I've got a sample extension up and running using dektopCapture but...

How to get chrome extension ID in dev and production?

I work on a chrome extension. I do use some messages between my web page and background process. Problem is: the ID of my application is different when it comes from the google extension page and the one I locally work on and debugging. Is there a way to make...

clearTimeout wont work

I have a full width slideshow. So I have a few problems with it. So the first one is: The second one is that clearTimeout wont work. If i call the function by a click so it should clear the Timeout. Do someone know why this wont work? Please explain...

IndexedDB: Can you manually initiate a version change transaction?

I am writing a chrome extension that utilizes IndexedDB to store some information client side in an IDBObjectStore within an IDBDatabase. The nature of the data is such that I need my users to be able to modify the object store at their whim. (add new objects modify existing ones...

Mismatched anonymous define() in Chrome extension content script

I'm trying to build a Chrome extension with TypeScript. The setup is quite simple: In manifest.json { "permissions": [ "webRequest", "webRequestBlocking", "tabs", "storage", "http://*/", "https://*/*" ], "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], "js": [ "scripts/require.js", "scripts/require-cs.js", "scripts/main.js", "scripts/contentscript.js" ], "run_at": "document_end", "all_frames": true }], } In model.ts: export...

Chrome extension console.log override

I'm building a chrome extension that reads the console log and find where an ip appears, after the string "Connecting to", and gets the ip. store = []; var oldf = console.log; console.log = function(){ store.push(arguments); oldf.apply(console, arguments); }; pos = 0 server = "" setTimeout(function(){ for(i = 0; i...

How to prevent timeout when running a time consuming PHP

I use PHP that gets so many data from several sites and write those data to the server which make files greater than 500 MB, but the process fails in between giving a 500 INTERNAL ERROR, but to adjust the timeout time of the php so that the process runs...

can't submit form in chrome extension

I have been working in a new chrome extension, and i am Beginner I have a form with login details (username and password) and i want to check username and password with database and move to another page or form in this extension. popup file Local Storage Encoding Local Storage...

Event for Chrome Google account logout or Google account user switch

Is there an event or listener that fires when a user logs his Google account out of Chrome (or switches from account)? When this happens I want to change my Chrome Extension default_icon (from green to red)....

How to increase timeout of DataAdapter to 3 min?

When i execute a query with the following method, i get a timeout. So my question is: how can i set the timeout to 180 seconds? I'm using the connection to fill the dataSet with the queryresult. internal static DataSet executeQuery(string queryString) { // #connection DataSet dataSet = new DataSet();...

How to respond to multiple bookmark operations in Chrome?

I'm working on a simple Chrome extension which deals with bookmarks. So far I've discovered two ways to respond to operations that the chrome.bookmarks API provides: pass callback function directly to the API call (eg. chrome.bookmarks.move(string id, object destination, function callback)) register callback function globally (chrome.bookmarks.onMoved.addListener(function callback)) As far as...

Chrome Extension - How to execute a JS script on page load

The following is that I'm trying to achieve Every time '' loads, a script/function triggers. However, the functions itself reloads the page via 'location.reload();' Basically, an infinite loop of reloads. Script reloads page -> Script injected -> Script reloads page -> etc. I want the tab @ to keep...

Adding eventListeners to checkboxes in for loop in chrome-extension

I have a function that gets all the tabs in a window and then updates the popup.html page by adding a checkbox for each tab. After doing this there is a second for loop that adds event listeners which update an dictionary containing the value of the checkbox's. The problem...

Constantly check the length of an element and perform an action if it is ever 1

I have an element on a page that I am constantly monitoring. If at any time that length is equal to 1, it means it exists on the page (the user has logged out) and I want to prompt them with a popup to login. So at the moment I...

Can Chrome extension content script access all tabs?

Basically, I want to get all the opened tabs of the browser window, from within a tab, more specifically, in content script. I tried chrome.tabs.query, it works in background script, but doesn't work in content script. So my questions are: Is there a way to do such work? Maybe an...

Using openweathermap api for free

Can I use openweathermap api for free in a chrome extension? I am trying to build a chrome extension which will use openweather map api. Can I use it for free if I want to place it on webstore?

What is the name of the language in which the main program of Chromium is written?

We would like to develop a new plugin for Chromium. To achieve this goal, we must learn at least one computer language. We do not know its / their name(s). Do you know the name of the computer language in which is written the program contains 1) the variable whose...

Is it possible to install timeout in OpenWRT

I need to execute a command with a timeout in OpenWRT, but it seems that the command timeout is not installed by default neither can be installed using opkg. I know that I can do a work around (using command &; sleep $DELAY; kill $!), but I wish to do...

Chrome extension, custom context menu item not showing [duplicate]

This question already has an answer here: Chrome extension context menu not showing up 1 answer I know this question has been asked so many times on this site, e.g. this post. However, Chrome upgrades so fast and it seems those solutions don't work for the latest version anymore....

Is there any way to detect javascript postmessages using chrome extension?

Does anybody sees a way to listen to cross iframe/window communication that is being done using the javascript postMessages ? Best would be using the chrome.debugger in the background page of an extension. I see that I can listen to HTTP-Traffic using the "Network.requestWillBeSent" and "Network.responseReceived" events. But I would...

JQuery .find() failing on an .ajax() result

I'm working on a Chrome extension which, under certain conditions, performs a $.ajax() request and then uses information of specific elements in the returned HTML. For now, I'm simply trying to have it access the specific element and log it to the console to ensure it works correctly. To start,...

Why does chrome.tabs.create create 2 tabs?

When the chrome.tabs.create function is triggered by a message received, it creates 2 tabs. In the following demo code, 1 cat tab is created, and 2 dog tabs are created. Is this by design or is it a bug? If it is a known bug, can you provide the bug...

Simple Chrome Extension : Open an url in a new tab

I'm looking to create a "new tab" extension like Panda or the Product Hunt Extension: the user can open a new tab with my website inside, with an hidden url. I've generated my package with the awesome Extensionizr and here is my manifest.json : manifest.json { "name": "My app", "version":...

Is there a way to view in Developer Tools?

I have a Chrome Extension and I'm able to view background page localStorage on the Resources tab of Developer Tools. Is there a way to do the some for

How to make function in loop run synchronously?

Am working on a chrome plugin, and need to sendMessage from an 'app page' to a 'content script' and then get the return messages, from inside a loop. But since the loop doesn't wait for the sendMessage to return a value before starting on the next iteration, it is screwing...

Meta tags in chrome extension manifest.json?

I'll give a contrived example: Imagine that I wanted to list my Chrome extension on the Chrome Web Store under the title "Brad's Animal Names Extension" but I also wanted my extension to be revealed in the search results for "elephant". Is there any way I can do this without...

when chrome extension gets updated does the data stored in local storage gets deleted?

I have searched through google spec about chrome storage, but was not able to get a definite answer to my question. I am currently writing my first chrome extension, in which I store the data into a local storage. The thing that is bothering me is that when I release...

Access DOM elements data document->Iframe ->Iframe->method chrome extension

I'm trying to access some data from an iframe nested within an iframe, from developers console: Object.keys(document.getElementById("contentBody"). contentDocument.getElementById('rawContent'). contentDocument.defaultView.window.messages) ["", "", "", "", "", ""] That's what I expect back, but I've tried to get that...

My Chrome Extension Keeps Saying Its Corrupted

I recently got a Chrome Developer account, i paid the 5 bucks and stuff. I published my extension after extensive testing and it works perfectly, but after i uploaded the app and then downloaded it to test it, whenever i try to open it, it disappears from my chrome bar...

Run a function from injected js

I have been going around in circles with this, so I would appreciate some help This is what I want to achieve User presses my extension ison Popup appears with two buttons, 'run function a' and 'run function b' When they press a button it runs the function in my...

chrome extensions Uncaught ReferenceError: $ is not defined

I am trying to make a chrome extension that uses an external javascript file that uses JQuery. But I keep getting this silly error. Screenshot of error in chrome inspector. Any help is appreciated thanks! popup.js $(document).ready(function(){ $.ajax({url: "", success: function(result){ $("#report-details").html(result); }}); }); popup.html <!doctype html> <html> <head> <title>TEST</title>...

How do I implement a timeout when using File.Copy?

I'm using System.IO.File.Copy to copy a file from a remote share to my local system. How can I implement a timeout if the copy takes too long?

Example mq_timedreceive

I can not find how to work properly with mq_timedreceive, can anyone give me an example? ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, const struct timespec *abs_timeout); I want timereceive to do not spent more than 20 seconds waiting. Thank you very much....

Are there any Chrome-specific techniques to scope/isolate CSS?

I'm writing a Chrome extension that injects HTML into a displayed page. I want the injected HTML to have it's own style, protected from the CSS that may be present in the host page. I've tried using conventional CSS, and still suffer from style corruption from the host page. After...