Advertisement
difool2nice

BrowserToolbox.uc.js

Apr 2nd, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //  browsertoolbox.uc.js
  2.  
  3. (function() {
  4.     if (location != 'chrome://browser/content/browser.xul')
  5.         return;
  6.  
  7.     try {
  8.         CustomizableUI.createWidget({
  9.             id: 'browser-toolbox-button',
  10.             defaultArea: CustomizableUI.AREA_NAVBAR,
  11.             label: 'Browser-Toolbox',
  12.             tooltiptext: 'Browser-Toolbox',
  13.             onCommand: function(event) {
  14.                 onCommand(event);
  15.             }
  16.         });
  17.     } catch (e) {
  18.         return;
  19.     };
  20.  
  21.     var css = '\
  22.         @-moz-document url("chrome://browser/content/browser.xul") { \
  23.             #browser-toolbox-button { \
  24.                 list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAdUlEQVQokZVSwRHAIAgLPYfoXs7RCTpG53Avt7APrhaFU8gLMEEJAkEQgFbc7IxkVjt0r6Sp7VIVITumBpKt00FA2ThmjXzkfMMWO8EZFSj8LrUyjsG9b9DaJXq+qAIVxEUxtLHpaXE95dj1NcK2rmbwaGJ4Af0tIg00j/6iAAAAAElFTkSuQmCC) \
  25.                         } ;\
  26.         }';
  27.     var cssUri = Services.io.newURI('data:text/css,' + encodeURIComponent(css), null, null);
  28.     var SSS = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
  29.     SSS.loadAndRegisterSheet(cssUri, SSS.AGENT_SHEET);
  30.  
  31.     Cu.import('resource://gre/modules/Timer.jsm');
  32.  
  33.     function onCommand(event) {
  34.  
  35.         var listenOpen = {
  36.             observe: function(aSubject, aTopic, aData) {
  37.                 if (aTopic != 'domwindowopened')
  38.                     return;
  39.                 var newWin = aSubject;
  40.                 newWin.addEventListener('load', function onLoad() {
  41.                     setTimeout(function() {
  42.                         doNewWin(newWin);
  43.                         newWin.removeEventListener('load', onLoad);
  44.                     }, 0);
  45.                 });
  46.             }
  47.         };
  48.  
  49.         function doNewWin(newWin) {
  50.             const dialogText = 'Eine eingehende Anfrage für eine externe Debugger-Verbindung wurde erkannt.'
  51.             if (newWin.location == 'chrome://global/content/commonDialog.xul' &&
  52.                 newWin.document.getElementById('info.body').textContent.startsWith(dialogText)) {
  53.                 var button = newWin.document.getAnonymousElementByAttribute(
  54.                     newWin.document.documentElement, 'dlgtype', 'accept');
  55.                 button.click();
  56.                 Services.ww.unregisterNotification(listenOpen);
  57.                 clearTimeout(tId);
  58.             };
  59.         };
  60.  
  61.         Services.ww.registerNotification(listenOpen);
  62.         var document = event.target.ownerDocument;
  63.         if (!document.getElementById('menu_browserToolbox')) {
  64.             let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
  65.             require("devtools/client/framework/devtools-browser");
  66.         };
  67.         document.getElementById('menu_browserToolbox').click();
  68.         var tId = setTimeout(function() {
  69.             Services.ww.unregisterNotification(listenOpen);
  70.         }, 5000);
  71.     };
  72.  
  73. })(); //    browsertoolbox.uc.js
  74.  
  75. (function() {
  76.     if (location != 'chrome://browser/content/browser.xul')
  77.         return;
  78.  
  79.     try {
  80.         CustomizableUI.createWidget({
  81.             id: 'browser-toolbox-button',
  82.             defaultArea: CustomizableUI.AREA_NAVBAR,
  83.             label: 'Browser-Werkzeuge',
  84.             tooltiptext: 'Browser-Werkzeuge',
  85.             onCommand: function(event) {
  86.                 onCommand(event);
  87.             }
  88.         });
  89.     } catch (e) {
  90.         return;
  91.     };
  92.  
  93.     var css = '\
  94.         @-moz-document url("chrome://browser/content/browser.xul") { \
  95.             #browser-toolbox-button { \
  96.                 list-style-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAdUlEQVQokZVSwRHAIAgLPYfoXs7RCTpG53Avt7APrhaFU8gLMEEJAkEQgFbc7IxkVjt0r6Sp7VIVITumBpKt00FA2ThmjXzkfMMWO8EZFSj8LrUyjsG9b9DaJXq+qAIVxEUxtLHpaXE95dj1NcK2rmbwaGJ4Af0tIg00j/6iAAAAAElFTkSuQmCC) \
  97.             } \
  98.         }';
  99.     var cssUri = Services.io.newURI('data:text/css,' + encodeURIComponent(css), null, null);
  100.     var SSS = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
  101.     SSS.loadAndRegisterSheet(cssUri, SSS.AGENT_SHEET);
  102.  
  103.     Cu.import('resource://gre/modules/Timer.jsm');
  104.  
  105.     function onCommand(event) {
  106.  
  107.         var listenOpen = {
  108.             observe: function(aSubject, aTopic, aData) {
  109.                 if (aTopic != 'domwindowopened')
  110.                     return;
  111.                 var newWin = aSubject;
  112.                 newWin.addEventListener('load', function onLoad() {
  113.                     setTimeout(function() {
  114.                         doNewWin(newWin);
  115.                         newWin.removeEventListener('load', onLoad);
  116.                     }, 0);
  117.                 });
  118.             }
  119.         };
  120.  
  121.         function doNewWin(newWin) {
  122.             const dialogText = 'Eine eingehende Anfrage für eine externe Debugger-Verbindung wurde erkannt.'
  123.             if (newWin.location == 'chrome://global/content/commonDialog.xul' &&
  124.                 newWin.document.getElementById('info.body').textContent.startsWith(dialogText)) {
  125.                 var button = newWin.document.getAnonymousElementByAttribute(
  126.                     newWin.document.documentElement, 'dlgtype', 'accept');
  127.                 button.click();
  128.                 Services.ww.unregisterNotification(listenOpen);
  129.                 clearTimeout(tId);
  130.             };
  131.         };
  132.  
  133.         Services.ww.registerNotification(listenOpen);
  134.         var document = event.target.ownerDocument;
  135.         if (!document.getElementById('menu_browserToolbox')) {
  136.             let { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
  137.             require("devtools/client/framework/devtools-browser");
  138.         };
  139.         document.getElementById('menu_browserToolbox').click();
  140.         var tId = setTimeout(function() {
  141.             Services.ww.unregisterNotification(listenOpen);
  142.         }, 5000);
  143.     };
  144.  
  145. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement