h4ckr14

Untitled

Jul 27th, 2016
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function determineActiveURL(callback) {
  2.     var b = window.URL || window.webkitURL,
  3.         tabURL, parsedURL;
  4.     chrome.tabs.query({
  5.         active: true,
  6.         windowId: chrome.windows.WINDOW_ID_CURRENT
  7.     }, function(tabs) {
  8.       if (!tabs || tabs.length == 0 || !tabs[0].url) {
  9.         return;
  10.       }
  11.       tabURL = tabs[0].url;
  12.       parsedURL = new window.URL(tabURL);
  13.       if (parsedURL.hostname) {
  14.         callback(parsedURL);
  15.       }
  16.     })
  17. }
Add Comment
Please, Sign In to add comment