javascript - Chrome to read when window is focused,aka opened -


i still new @ programing. have played around javascript before, still tricky me.

i got great idea extension google chrome- in future nice port other browsers. think google chrome easiest way develop for.

i investigated little , finished kitties tutorial on extensions site.

from there makes sense- easy part, idea sounds impossible me. simply, extension automatically reload browser when window selected or focused on screen. saves time not pressing ctrl+r (pc), or cmd+r (mac), or reload button every time developer checks update on code.

i reading through api documentation , found method chrome.browseraction.onclick, there chrome.browseraction.focused? idea feasible?

i have take in consideration chrome visited multiple os. wonder if mac os, linux, , windows version need different javascript instruction pull off? simple idea overwhelming...

thanks input in advance :)

sounds you'll want use chrome.windows.onfocuschanged:

fired when focused window changes. chrome.windows.window_id_none if chrome windows have lost focus. note: on linux window managers, window_id_none sent preceding switch 1 chrome window another.

here's example of how reload newly-focused window's active tab:

chrome.windows.onfocuschanged.addlistener(function(windowid) {     if (windowid != chrome.windows.window_id_none) {         chrome.tabs.query({ active:true, windowid:windowid }, function(tabs) {             if (tabs.length == 1) {                 var tab = tabs[0];                 chrome.tabs.reload(tab.id);             }         });     } }); 

you'll need declare tabs permission in manifest.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -