cdtylh06
狐狸大王
狐狸大王
  • UID33490
  • 注册日期2010-07-21
  • 最后登录2018-09-03
  • 发帖数459
  • 经验113枚
  • 威望0点
  • 贡献值30点
  • 好评度4点
  • 社区居民
  • 忠实会员
阅读:2214回复:0

firefox4有可以把附加组件栏的图标放到地址栏上的脚本吗??

楼主#
更多 发布于:2011-02-08 21:19
// ==UserScript==
// @name           ChromeStatuѕbarModoki.uc.js
// @namespace      http://d.hatena.ne.jp/Griever/
// @include        main
// @compatibility  Firefox 4.0b8
// @version        0.0.6
// @note           マウスオーバーで右に行かなくなってたのを修正
// ==/UserScript==
// Firefox 3.6, 4.0b6 は古い Ver. を使ってください
// https://gist.github.com/300255/4144baa9 ... 038822fa12

(function(css) {
    if (!$('addon-bar')) return;

    if (window.chromeStatuѕbar) {
        css = '';
        chromeStatuѕbar.destory();
    } else {

        if (!XULBrowserWindow.setOverLink_org) {
            XULBrowserWindow.setOverLink_org = XULBrowserWindow.setOverLink;
            XULBrowserWindow.setOverLink = function (url, anchorElt) {
                window.chromeStatuѕbar.setOverLink(url);
            }
        }

        XULBrowserWindow._status = '';
        XULBrowserWindow.__defineSetter__('status', function(status) {
            window.chromeStatuѕbar.status = status;
            window.chromeStatuѕbar.updateStatusField(true);
            return this._status = status;
        });
        XULBrowserWindow.__defineGetter__('status', f unction() {
            return this._status;
        });
    }

    var ns = window.chromeStatuѕbar = {
        duration: 250,
        delay   : 2000,

        _timeout: null,
        get timeout() ns._timeout,
        set timeout(timer) {
            if (ns._timeout) clearTimeout(ns._timeout);
            return ns._timeout = timer;
        },

        _resizeTimer: null,
        get resizeTimer() ns._resizeTimer,
        set resizeTimer(timer) {
            if (ns._resizeTimer) clearTimeout(ns._resizeTimer);
            return ns._resizeTimer = timer;
        },

        overLink : "",
        status : "",
        statusText : "",

        setOverLink : function (link) {
            this.overLink = link.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g, encodeURIComponent);
            this.updateStatusField();
        },

        updateStatusField: function(no_hide) {
            var text = ns.overLink || ns.status;
            ns.no_hide = no_hide;
            ns.display.label = text;
            ns.statusText = text;
        },

        init: f unction() {
            if (css)
                addStyle(css);

            var statuѕBar = $('statuѕ-bar');
            if (isElementVisible(gURLBar)) {
                var urlbarIcons = $('urlbar-icons');
                var stylishPanel = $('stylish-toolbar-button');
                if(stylishPanel){
                    stylishPanel.setAttribute("id","stylish-panel");
                    stylishPanel.onclick = function(event){
                    stylishOverlay.handleStatusClick(event);
                };
                statuѕBar.appendChild(stylishPanel);
                }
                urlbarIcons.insertBefore(statuѕBar, urlbarIcons.firstChild);
                statusBar.setAttribute('context', '');
            }

            ns.hbox = document.createElement('hbox');
            ns.hbox.id = 'chrome-status';
            ns.hbox.setAttribute('onmouseover', 'chromeStatusbar.onMouseover(event);');
            ns.hbox.hidden = true;
            ns.display = ns.hbox.appendChild(document.createElement('label'));
            ns.display.id = 'chrome-status-label';
            ns.display.setAttribute('crop', 'center');
            ns.display.__defineGetter__('label', f unction(){
                return this.getAttribute('value');
            });
            ns.display.__defineSetter__('label', function(str){
                ns.show(str);
                return str;
            });
            $('content').parentNode.insertBefore(ns.hbox, $('content').nextSibling);

            if (!XULBrowserWindow.statusTextField) {
                XULBrowserWindow.statusTextField = ns.display;
            }

            ns.hs = ns.hbox.style;
            ns.hs.opacity = 0;
            ns.hs.MozTransition = 'opacity ' + ns.duration + 'ms ease-out';
            //addEventListener('resize', ns.onResize, false);
            addEventListener('unload', ns.uninit, false);
        },

        uninit: f unction() {
            ns.timeout = null;
            ns.resizeTimer = null;
            //removeEventListener('resize', ns.onResize, false);
            removeEventListener('unload', ns.uninit, false);
        },

        destory: f unction() {
            ns.uninit();
            if (XULBrowserWindow.statusTextField === ns.display)
                XULBrowserWindow.statusTextField = null;
            ns.hbox.parentNode.removeChild(ns.hbox);
        },

        onResize: function(event) {
            ns.resizeTimer = setTimeout(f unction(){
                ns.resetStyle();
            }, 250);
        },

        onMouseover: function(event) {
            ns.display.classList.contains('right')?
                ns.display.classList.remove('right'):
                ns.display.classList.add('right');
            ns.right = !ns.right;
            ns.resetStyle();
        },

        resetStyle: f unction(){
            let contentRect = gBrowser.mPanelContainer.boxObject;
            if (true === ns.display.classList.contains('right')) {
                let w = Math.min(contentRect.width * 0.3, 400);
                ns.hs.maxWidth = w + 'px';
                ns.hs.minWidth = w + 'px';
                ns.hs.left = contentRect.x + contentRect.width - w + 'px';
            } else {
                let w = contentRect.width * 0.7;
                ns.hs.maxWidth = w + 'px';
                ns.hs.minWidth = Math.min(w, 400) + 'px';
                ns.hs.left = contentRect.x + 'px';
            }
            if (false === ns.hbox.hidden)
                ns.hs.marginTop = -ns.hbox.boxObject.height + 'px';
        },

        show: function(text) {
            if (!text) {
                if (false === ns.hbox.hidden)
                    ns.hide(ns.no_hide ? 0 : ns.delay);
                return;
            }

            if ('http://' === (text+'').substr(0, 7))
                text = (text+'').substr(7);

            ns.display.setAttribute('value', text);
            ns.timeout = null;
            if (true === ns.hbox.hidden) {
                ns.hbox.hidden = false;
                ns.resetStyle();
            }
            ns.hs.opacity = 1;
        },

        hide: function(hide_delay) {
            ns.timeout = setTimeout(f unction(){
                ns.hs.opacity = 0;
                ns.timeout = setTimeout(f unction(){
                    ns.hbox.hidden = true;
                    ns.display.classList.remove('right');
                    ns.display.setAttribute('value', ns.statusText = '');
                }, ns.duration);
            }, hide_delay || 0);
        },
    };

    ns.init();
    return;

    function log(){ Application.console.log(Array.slice(arguments).join('\n')); }
    function $(id) document.getElementById(id);
    function addStyle(css) {
        var pi = document.createProcessingInstruction(
            'xml-stylesheet',
            'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"'
        );
        return document.insertBefore(pi, document.documentElement);
    }


})(<![CDATA[
@namespace url(http://www.mozilla.org/keymaster/gateke ... s.only.xul);

#chrome-status {
  position: fixed !important;
}

#chrome-status-label {
  width: 100% !important;
  -moz-box-sizing: border-box !important;
  margin: 0px !important;
  padding: 1px 6px !important;
  border-top: 1px solid #bbd !important;
  border-right: 1px solid #bbd !important;
  border-left: 1px solid transparent !important;
  border-bottom: 1px solid transparent !important;
  -moz-border-radius-topright: 4px !important;

  background-color: #D2E1F6 !important;
  color: #333 !important;
}

#chrome-status-label.right {
  border-top: 1px solid #bbd !important;
  border-left: 1px solid #bbd !important;
  border-right: 1px solid transparent !important;
  border-bottom: 1px solid transparent !important;
  -moz-border-radius-topright: 0px !important;
  -moz-border-radius-topleft: 4px !important;
}

.urlbar-over-link-layer {
  display: none !important;
}
.urlbar-textbox-container-children {
  opacity: 1 !important;
}
#urlbar[pageproxystate="invalid"] > #urlbar-icons > .urlbar-icon:not(#go-button) {
  visibility: hidden !important;
}

#status-bar {
  min-height: 18px !important;
  margin: 0px !important;
  border: none !important;
  background-color: transparent !important;
}

#firegestures-status {
  margin-bottom: 20px !important;
}

/* Remove stylish button shape and place in the location bar */
#stylish-panel {
  -moz-appearance: none !important;
  border: 0 !important;
  background: white !important;
  box-shadow: white 0 0 !important;
  padding: 2px 4px !important;
  margin: -2px !important;
  position: fixed !important;
}

#stylish-panel > dropmarker{
  display: none !important;
}
]]>.toString());


这个脚本可以把附加组件栏图标放到地址栏,但还会显示网页加载进度在左下角,因为b11已经自带显示进度了,所以,麻烦把这个脚本的加载进度修改掉,只留图标放在地址栏就行了,麻烦高手修改下了!!!
游客

返回顶部