haruka123
小狐狸
小狐狸
  • UID57156
  • 注册日期2019-06-17
  • 最后登录2023-06-10
  • 发帖数5
  • 经验7枚
  • 威望0点
  • 贡献值8点
  • 好评度1点
  • 社区居民
阅读:3547回复:2

92.0 失效脚本求帮助

楼主#
更多 发布于:2021-09-06 20:18
BMMultiColumn.uc.js


location.href.startsWith('chrome://browser/content/browser.x') && (function () {
    if (window.BMMultiColumn) {
        window.BMMultiColumn.destroy();
        delete window.BMMultiColumn;
    }
      
    var BMMultiColumn = {
        cachedMenus: [],
        init: function () {
            $('PlacesToolbarItems').addEventListener('popupshowing', this, false);
            var pop = $('BMB_bookmarksPopup');
            if (pop) {
                pop.addEventListener('popupshowing', this, false);
                pop.addEventListener('click', this, false);
            }
        },
        destroy: function () {
            $('PlacesToolbarItems').removeEventListener('popupshowing', this, false);
            var pop = $('BMB_bookmarksPopup');
            if (pop) {
                pop.removeEventListener('popupshowing', this, false);
                pop.removeEventListener('click', this, false);
            }
      
            var i = 0;
            for (i = 0; i < this.cachedMenus.length; i++) {
                var menu = this.cachedMenus;
                if (menu && menu._x_inited) {
                    menu._x_scrollbox.width = '';
                    if( menu._scrollBox && menu._scrollBox.style){
                        menu._scrollBox.style.maxHeight = "";
                    }
                          
                    menu.style.maxWidth = "";
      
                    var container = menu._x_box;
                    if(container){
                        container.style.minHeight = "";
                        container.style.height = "";
                        container.style.display = "";
                        container.style.flexFlow = "";
                        container.style.overflow = "";
                    }
      
                    delete menu._x_scrollbox;
                    delete menu._x_inited;
                    delete menu._x_box;
                }
            }
            this.cachedMenus = [];
        },
        handleEvent: function (event) {
            var menupopup;
            if (event.target.tagName == 'menu') {
                menupopup = event.target.menupopup;
            } else if (event.target.tagName == 'menupopup') {
                menupopup = event.target;
            } else return;
            if (!menupopup) return;
            //没有初始化或换过位置,重新设置属性
            if (!menupopup.firstChild) return;
      
            if (!menupopup._x_inited || !menupopup._x_scrollbox.scrollWidth) {
                var scrollbox = menupopup.shadowRoot.querySelector('::part(arrowscrollbox) ');
   
                var box = scrollbox.shadowRoot.querySelector('[part=scrollbox]');
   
                if (box) {
                    menupopup._x_box = box;
                    menupopup._x_scrollbox = scrollbox;
                    if (!menupopup._x_inited) {
                        menupopup._x_inited = true;
                        this.cachedMenus.push(menupopup);
                    }
                }
                var container = menupopup._x_box;
                if(container){
                    container.style.minHeight = "21px";
                    container.style.height = "auto";
                    container.style.display = "inline-flex";
                    container.style.flexFlow = "column wrap";
                    //container.style.overflow = "auto";
                    container.style.overflow = "-moz-hidden-unscrollable";
                    menupopup._scrollBox.style.maxHeight = "calc(100vh - 129px)";
                }
                menupopup.style.maxWidth = "calc(100vw - 20px)";
            }
            if (menupopup._x_inited) {
                if (!(menupopup._x_scrollbox.clientWidth == menupopup._x_box.scrollWidth)) {
                    menupopup._x_scrollbox.width = menupopup._x_box.scrollWidth;
                }
                //弹出菜单点击bug,要计算两次
                if (event.type == "click") {
                   if (!(menupopup._x_scrollbox.clientWidth == menupopup._x_box.scrollWidth)) {
                       menupopup._x_scrollbox.width = menupopup._x_box.scrollWidth;
                   }
                }
                //如果菜单数量或者文字宽度发生变化,可能会多出空区域,重新计算下
                var menuitem = menupopup.lastChild;
                while (menuitem) {
                    if (!menuitem.style.maxWidth) {
                        menuitem.style.maxWidth = "300px";
                        menuitem.style.minWidth = "100px";
                    }
                    menuitem = menuitem.previousSibling;
                }
      
                var lastmenu = menupopup.lastChild;
                while (lastmenu) {
                    if (lastmenu.scrollWidth >= 90) break;
                    lastmenu = lastmenu.previousSibling;
                }
      
                if (lastmenu && lastmenu.scrollWidth >= 90) {
                    var pos1 = lastmenu.x - 0 + lastmenu.clientWidth;
                    var pos2 = menupopup._x_box.x - 0 + menupopup._x_box.clientWidth;
                    if (pos2 - pos1 > 30) {
                        menupopup._x_scrollbox.width = "";
                        menupopup._x_scrollbox.width = menupopup._x_box.scrollWidth;
                    }
                }
            }
        }
    }
    BMMultiColumn.init();
    window.BMMultiColumn = BMMultiColumn;
      
    function $(id) {
        return document.getElementById(id);
    }
})();
Restart-Panelbutton.uc.js
(function()
{
    var quitBtn = document.getElementById("appMenu-viewCache")?.content?.getElementById("appMenu-quit-button2") || document.getElementById("appMenu-quit-button");
    if (!quitBtn) return;
    
    var restartBtn = document.createXULElement("toolbarbutton");
    restartBtn.setAttribute("label", "\u91cd\u65b0\u542f\u52a8");
    restartBtn.setAttribute("class", "subviewbutton subviewbutton-iconic");
    restartBtn.setAttribute("id", "restart-button");
    restartBtn.style.listStyleImage= 'url(\'data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill="context-fill" fill-opacity="context-fill-opacity" d="M15,1a1,1,0,0,0-1,1V4.418A6.995,6.995,0,1,0,8,15a6.954,6.954,0,0,0,4.95-2.05,1,1,0,0,0-1.414-1.414A5.019,5.019,0,1,1,12.549,6H10a1,1,0,0,0,0,2h5a1,1,0,0,0,1-1V2A1,1,0,0,0,15,1Z"/></svg>\')';
    restartBtn.addEventListener("command", function()
    {
        const APP_START = Components.classes['@mozilla.org/toolkit/app-startup;1']
            .getService(Components.interfaces.nsIAppStartup);
        APP_START.quit(APP_START.eRestart | APP_START.eAttemptQuit);
    }, false);
    quitBtn.parentNode.insertBefore(restartBtn, quitBtn);
})();
谢谢大家
feelspace
小狐狸
小狐狸
  • UID27316
  • 注册日期2008-12-05
  • 最后登录2023-09-02
  • 发帖数14
  • 经验27枚
  • 威望0点
  • 贡献值0点
  • 好评度2点
  • 社区居民
1楼#
发布于:2021-09-11 12:26
userChromeJS 失效了吧,请更新

alice0775 方案 https://github.com/alice0775/userChrome.js/tree/master/92

Endor8 方案 https://github.com/Endor8/userChrome.js/tree/master/userChrome

更新后删除配置文件夹里的 startupCache
haruka123
小狐狸
小狐狸
  • UID57156
  • 注册日期2019-06-17
  • 最后登录2023-06-10
  • 发帖数5
  • 经验7枚
  • 威望0点
  • 贡献值8点
  • 好评度1点
  • 社区居民
2楼#
发布于:2021-09-12 21:41
feelspace:userChromeJS 失效了吧,请更新

alice0775 方案 https://github.com/alice0775/userChrome.js/tree/master/92

Endor8 方案 https://github...
回到原帖
非常感谢 成功了!
游客

返回顶部