谷歌大法好
狐狸大王
狐狸大王
  • UID49692
  • 注册日期2015-04-11
  • 最后登录2019-06-15
  • 发帖数301
  • 经验297枚
  • 威望0点
  • 贡献值224点
  • 好评度24点
  • 社区居民
  • 忠实会员
阅读:239回复:0

addonbaruc.js导致首次拉起firefox白屏

楼主#
更多 发布于:2019-03-05 12:37
https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/addonbar.uc.js

这个脚本会导致从第三方软件首次拉起浏览器时白屏,可是该作者其他的类似脚本
https://github.com/Aris-t2/CustomJSforFx/blob/master/scripts/addonbar_vertical.uc.js
却不会引起此类问题,作者说他也不知为啥。
大佬可否修改下下



// Add-on Bar script for Firefox 60+ by Aris
//
// no 'close' button
// 'toggle' toolbar with 'Ctr + /' on Windows/Linux or 'Cmd + /' on macOS
// no 'Add-on Bar' entry in toolbar context menu
//
// option: smaller buttons / reduced toolbar button height
//
// flexible spaces on add-on bar behave like on old Firefox versions
   
// [!] Fix for WebExtensions with own windows by 黒仪大螃蟹 (for 1-N scripts)
   
   
Components.utils.import("resource:///modules/CustomizableUI.jsm");
var {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
var appversion = parseInt(Services.appinfo.version);
   
var compact_buttons = false; // reduced toolbar height and smaller buttons
   
var AddAddonbar = {
  init: function() {
         
    try {
      if (document.getElementById('main-window').getAttribute('chromehidden')) {
        return gBrowser.selectedBrowser.removeAttribute('blank');
      }
    } catch(e) {}
   
    var addonbar_label = "Add-on Bar";
    var compact_buttons_code = "";
       
    if(compact_buttons)
      compact_buttons_code = "\
        #addonbar toolbarbutton .toolbarbutton-icon { \
          padding: 0 !important; \
          width: 16px !important; \
          height: 16px !important; \
        } \
        #addonbar .toolbarbutton-badge-stack { \
          padding: 0 !important; \
          margin: 0 !important; \
          width: 16px !important; \
          min-width: 16px !important; \
          height: 16px !important; \
          min-height: 16px !important; \
        } \
        #addonbar toolbarbutton .toolbarbutton-badge { \
          margin-top: 0px !important; \
          font-size: 8px !important; \
        } \
      ";
   
    // style sheet
    Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService).loadAndRegisterSheet(
      Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent('\
          \
          #addonbar toolbarpaletteitem[place=toolbar][id^=wrapper-customizableui-special-spring],\
          #addonbar toolbarspring {\
            -moz-box-flex: 1 !important;\
            min-width: 100% !important;\
            width: unset !important;\
            max-width: unset !important;\
          }\
          #main-window[customizing] #addonbar { \
            outline: 1px dashed !important; \
            outline-offset: -2px !important; \
          } \
          #addonbar { \
            border-top: 1px solid var(--sidebar-border-color,rgba(0,0,0,0.1)) !important; \
          } \
          '+compact_buttons_code+'\
      '), null, null),
      Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService).AGENT_SHEET
    );
   
    // toolbar
    try {
      var tb_addonbar = document.createXULElement("toolbar");
      if(appversion <= 62) tb_addonbar = document.createElement("toolbar");
      tb_addonbar.setAttribute("id","addonbar");
      tb_addonbar.setAttribute("collapsed", "false");
      tb_addonbar.setAttribute("toolbarname", addonbar_label);
      tb_addonbar.setAttribute("defaultset","spring,spring"); 
      tb_addonbar.setAttribute("customizable","true");
      tb_addonbar.setAttribute("mode","icons");
      tb_addonbar.setAttribute("iconsize","small");
      tb_addonbar.setAttribute("context","toolbar-context-menu");
      tb_addonbar.setAttribute("lockiconsize","true");
      tb_addonbar.setAttribute("class","toolbar-primary chromeclass-toolbar browser-toolbar customization-target");
   
      document.getElementById("browser-bottombox").appendChild(tb_addonbar);
         
      CustomizableUI.registerArea("addonbar", {legacy: true});
     
      if(appversion >= 65) {
        CustomizableUI.registerToolbarNode(tb_addonbar);
        // broken tab workaround
        let tab = gBrowser.selectedTab;
        gBrowser.duplicateTab(tab);
        gBrowser.removeTab(tab);
      }
       
      // 'Ctr + /' on Windows/Linux or 'Cmd + /' on macOS to toggle add-on bar
      var key = document.createElement('key');
      key.id = 'key_toggleAddonBar';
      key.setAttribute('key', '/');
      key.setAttribute('modifiers', 'accel');
      key.setAttribute('oncommand',
        'var newAddonBar = document.getElementById("addonbar"); setToolbarVisibility(newAddonBar, newAddonBar.collapsed);');
      document.getElementById('mainKeyset').appendChild(key);
         
    } catch(e) {}
   
  }
   
}
   
setTimeout(function(){
  AddAddonbar.init();
},500);
游客

返回顶部