Advertisement
Guest User

Chrome extension, console log tab and window events

a guest
Jul 29th, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. chrome.tabs.onCreated.addListener(
  2.     function(tab)
  3.     {
  4.         console.groupCollapsed('tab created');
  5.         console.log(tab);
  6.         console.log('tab id', tab.id);
  7.         console.log('tab index', tab.index);
  8.         console.log('tab url', tab.url);
  9.         console.log('tab title', tab.title);
  10.         console.log('tab object', tab);
  11.         console.groupEnd();
  12.     }
  13. );
  14. chrome.tabs.onUpdated.addListener(
  15.     function(tabId, changeInfo, tab)
  16.     {
  17.         console.groupCollapsed('tab updated');
  18.         console.log('tab id', tabId);
  19.         console.log('tab index', tab.index);
  20.         console.log('tab url', tab.url);
  21.         console.log('tab title', tab.title);
  22.         console.log('change info status', changeInfo.status);
  23.         console.log('change info url', changeInfo.url);
  24.         console.log('change info title', changeInfo.title);
  25.         console.log('change info audible', changeInfo.audible);
  26.         if (changeInfo.mutedInfo)
  27.         {
  28.             console.log('change info muted info muted', changeInfo.mutedInfo.muted);
  29.             console.log('change info muted info reason', changeInfo.mutedInfo.reason);
  30.             console.log('change info muted info extension id', changeInfo.mutedInfo.extensionId);
  31.         }
  32.         console.log('muted info', mutedInfo);
  33.         console.log('change info', changeInfo);
  34.         console.log('tab object', tab);
  35.         console.groupEnd();
  36.     }
  37. );
  38. chrome.tabs.onMoved.addListener(
  39.     function(tabId, moveInfo)
  40.     {
  41.         console.groupCollapsed('tab moved');
  42.         console.log('tab id', tabId);
  43.         console.log('move info window id', moveInfo.windowId);
  44.         console.log('move info from index', moveInfo.fromIndex);
  45.         console.log('move info to index', moveInfo.toIndex);
  46.         console.log('move info', moveinfo);
  47.         console.groupEnd();
  48.     }
  49. );
  50. chrome.tabs.onActivated.addListener(
  51.     function(activeInfo)
  52.     {
  53.         console.groupCollapsed('tab activated');
  54.         console.log('active info tab id', activeInfo.tabId);
  55.         console.log('active info window id', activeInfo.windowId);
  56.         console.log('active info', activeInfo);
  57.         console.groupEnd();
  58.     }
  59. );
  60. chrome.tabs.onHighlighted.addListener(
  61.     function(highlightInfo)
  62.     {
  63.         console.groupCollapsed('tab highlighted');
  64.         console.log('highlight info window id', highlightInfo.windowId);
  65.         console.log('highlight info tabIds', highlightInfo.tabIds);
  66.         console.log('highlight info', highlightInfo);
  67.         console.groupEnd();
  68.     }
  69. );
  70. chrome.tabs.onDetached.addListener(
  71.     function(tabId, detachInfo)
  72.     {
  73.         console.groupCollapsed('tab detached');
  74.         console.log('tab id', tabId);
  75.         console.log('detach info old window id', detachInfo.oldWindowId);
  76.         console.log('detach info old position', detachInfo.oldPosition);
  77.         console.log('detach info', detachInfo);
  78.         console.groupEnd();
  79.     }
  80. );
  81. chrome.tabs.onAttached.addListener(
  82.     function(tabId, attachInfo)
  83.     {
  84.         console.groupCollapsed('tab attached');
  85.         console.log('tab id', tabId);
  86.         console.log('attach info new window id', attachInfo.newWindowId);
  87.         console.log('attach info new position', attachInfo.newPosition);
  88.         console.log('attach info', attachInfo);
  89.         console.groupEnd();
  90.     }
  91. );
  92. chrome.tabs.onRemoved.addListener(
  93.     function(tabId, removeInfo)
  94.     {
  95.         console.groupCollapsed('tab removed');
  96.         console.log('tab id', tabId);
  97.         console.log('remove info window id', removeInfo.windowId);
  98.         console.log('remove info is window closing', removeInfo.isWindowClosing);
  99.         console.log('remove info', removeInfo);
  100.         console.groupEnd();
  101.     }
  102. );
  103. chrome.tabs.onReplaced.addListener(
  104.     function(addedTabId, removedTabId)
  105.     {
  106.         console.groupCollapsed('tab replaced');
  107.         console.log('added tab id', addedTabId);
  108.         console.log('removed tab id', removedTabId);
  109.         console.groupEnd();
  110.     }
  111. );
  112. chrome.tabs.onZoomChange.addListener(
  113.     function(zoomChangeInfo)
  114.     {
  115.         console.groupCollapsed('tab zoom changed');
  116.         console.log('tab id', zoomChangeInfo.tabId);
  117.         console.log('old zoom', zoomChangeInfo.oldZoomFactor);
  118.         console.log('new zoom', zoomChangeInfo.newZoomFactor);
  119.         console.log('zoom change info', zoomChangeInfo);
  120.         console.groupEnd();
  121.     }
  122. );
  123. chrome.windows.onCreated.addListener(
  124.     function(window)
  125.     {
  126.         console.groupCollapsed('window created');
  127.         console.log('window id', window.id);
  128.         console.log('window type', window.type);
  129.         console.log('window is incognito', window.incognito);
  130.         console.log('window state', window.state);
  131.         console.log('window object', window);
  132.         console.groupEnd();
  133.     }
  134. );
  135. chrome.windows.onRemoved.addListener(
  136.     function(windowId)
  137.     {
  138.         console.groupCollapsed('window removed');
  139.         console.log('window id', windowId);
  140.         console.groupEnd();
  141.     }
  142. );
  143. chrome.windows.onFocusChanged.addListener(
  144.     function(windowId)
  145.     {
  146.         console.groupCollapsed('window focused');
  147.         console.log('window id', windowId);
  148.         console.groupEnd();
  149.     }
  150. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement