MozTW 討論區

各項 Mozilla 相關軟體與技術討論
現在的時間是 2024-04-17, 02:06

所有顯示的時間為 UTC + 8 小時





發表新文章 回覆主題  [ 36 篇文章 ]  前往頁數 123  下一頁
發表人 內容
文章發表於 : 2007-03-01, 23:06 
離線
頭像

註冊時間: 2005-08-25, 19:59
文章: 1210
來自: 幻境地帶
userChrome.js - allows to easily customize Firefox through JavaScript.

有些小功能可以用 userChrome.js 這個小套件簡單達成,就不用多花時間特別弄一個套件出來。

_________________
Add Bookmark Here ² | Charset Switcher | Hide Menubar | MClickFocusTab | Personal Titlebar


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
文章發表於 : 2007-03-01, 23:10 
離線
頭像

註冊時間: 2005-08-25, 19:59
文章: 1210
來自: 幻境地帶
代碼:
(function() {
   //公用函式
   function hookCode(orgFunc, orgCode, myCode) {
      eval(orgFunc + "=" + eval(orgFunc).toString().replace(orgCode, myCode));
   }
   //當新增分頁時能自動利用尾端空白分頁
   hookCode("getBrowser().addTab", "return t;", (
      function() {
         if ((aURI != "about:blank")
            &&(["removeTab","sss_restoreWindow","sss_undoCloseTab"].indexOf(this.addTab.caller.name) == -1)
            &&(!t.previousSibling.linkedBrowser.webProgress.isLoadingDocument)
            &&(t.previousSibling.linkedBrowser.currentURI.spec == "about:blank"))
         {
            this.removeTab(t.previousSibling);
         }
      }
   ).toString().replace(/^.*{/,"").replace(/.*}$/,"")+"$&");
})();

_________________
Add Bookmark Here ² | Charset Switcher | Hide Menubar | MClickFocusTab | Personal Titlebar


最後由 yuoo2k 於 2010-02-05, 22:18 編輯,總共編輯了 2 次。

回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
文章發表於 : 2007-03-01, 23:12 
離線
頭像

註冊時間: 2005-08-25, 19:59
文章: 1210
來自: 幻境地帶
代碼:
(function() {
   //公用函式
   function hookCode(orgFunc, orgCode, myCode) {
      eval(orgFunc + "=" + eval(orgFunc).toString().replace(orgCode, myCode));
   }
   //巴哈姆特外部鏈結用中鍵點擊可直接開啟
   hookCode("openNewTabWith", /{/, "{" + (
      function() {
         if (arguments[3] && arguments[3].button == 1) {
            var m = arguments[0].match(/^javascript:(top\.)?confirmLink\(\s*(\x22|\x27)(.*)(\x22|\x27)\s*\)$/);
            if (m) arguments[0] = unescape(m[3]);
         }
      }
   ).toString().replace(/^.*{/,"").replace(/.*}$/,""));
})();

_________________
Add Bookmark Here ² | Charset Switcher | Hide Menubar | MClickFocusTab | Personal Titlebar


最後由 yuoo2k 於 2008-06-27, 23:47 編輯,總共編輯了 2 次。

回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
文章發表於 : 2007-03-01, 23:18 
離線
頭像

註冊時間: 2005-08-25, 19:59
文章: 1210
來自: 幻境地帶
代碼:
var gSearchBox = {
   get ref() {
      return document.getElementById("searchbar");
   },
   get textbox() {
      return document.getAnonymousElementByAttribute(this.ref, "class", "searchbar-textbox");
   },
   get goButton() {
      return document.getAnonymousElementByAttribute(this.ref, "class", "search-go-button");
   },
   get engineButton() {
      return document.getAnonymousElementByAttribute(this.ref, "class", "searchbar-engine-button");
   },
   get value() {
      if (this.textbox) return this.textbox.inputField.value;
   },
   set value(v) {
      if (this.textbox) {
         this.textbox.focus();
         this.textbox.inputField.value = v;
         var e = document.createEvent("HTMLEvents");
         e.initEvent("oninput", true, false);
         this.textbox.dispatchEvent(e);
      }
   }
}

//使用 滑鼠中鍵 點擊 搜尋欄位 時,可直接 清除目前搜尋欄 的內容。
gSearchBox.textbox.addEventListener("click",
function(event) {
   if (event.button == 1) {
      gSearchBox.value = "";
   }
}, false);

//使用 滑鼠右鍵 點擊 搜尋按鈕 時,可直接 貼上目前剪貼簿 的內容。
gSearchBox.goButton.addEventListener("click",
function(event) {
   if (event.button == 2) {
      var data = readFromClipboard(); if (!data) data = "";
      data = data.replace(/(^\s*|\s*$)/g, "");
      gSearchBox.value = data;
      event.preventDefault();
   }
}, false);

//使用 滑鼠中鍵 點擊 引擎切換選單 時,可使用該引擎 搜尋目前搜尋欄 的內容。
//使用 滑鼠右鍵 點擊 引擎切換選單 時,可使用該引擎 搜尋目前剪貼簿 的內容。
gSearchBox.engineButton.addEventListener("click",
function(event) {
   if ((event.button == 1)||(event.button == 2)) {
      var data = gSearchBox.value;
      if (gSearchBox.ref.getAttribute("empty") == "true") data = "";
      if (event.button == 2) {
         data = readFromClipboard(); if (!data) return;
      }
      data = data.replace(/(^\s*|\s*$)/g, "");
      var engine = event.originalTarget.engine;
      var anonid = event.originalTarget.getAttribute("anonid");
      if (!engine && anonid != "searchbar-engine-button") return;
      if (engine) gSearchBox.ref.currentEngine = engine;
      gSearchBox.value = data;
      gSearchBox.ref.doSearch(data, true);
      gSearchBox.ref._popup.hidePopup();
   }
}, false);

_________________
Add Bookmark Here ² | Charset Switcher | Hide Menubar | MClickFocusTab | Personal Titlebar


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2007-03-02, 11:13 
離線

註冊時間: 2007-01-07, 19:46
文章: 1153
來自: :) 星火
真的是好东西!收了.


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2007-03-02, 18:17 
離線

註冊時間: 2005-06-27, 15:59
文章: 466
來自: Republic of China ( R.O.C. )
感謝yuoo2k大整理這些好用的功能,真是一大福音,小弟要趕緊來試試。


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.1) Gecko/20070204 BonEcho/2.0.0.1 (tete009 MMX PGO)
 個人資料  
引用回覆  
文章發表於 : 2007-03-02, 21:10 
離線
頭像

註冊時間: 2005-08-25, 19:59
文章: 1210
來自: 幻境地帶
代碼:
(function() {
   function hookCode(orgFunc, orgCode, myCode) {
      try { eval(orgFunc + "=" + eval(orgFunc).toString().replace(orgCode, myCode)); }catch(e){ Components.utils.reportError("Failed to hook function: "+orgFunc); }
   }

   function hookProp(parentNode, propName, myGetter, mySetter) {
      var oGetter = parentNode.__lookupGetter__(propName);
      var oSetter = parentNode.__lookupSetter__(propName);
      if (oGetter && myGetter) myGetter = oGetter.toString().replace(/{/, "{"+myGetter.toString().replace(/^.*{/,"").replace(/.*}$/,""));
      if (oSetter && mySetter) mySetter = oSetter.toString().replace(/{/, "{"+mySetter.toString().replace(/^.*{/,"").replace(/.*}$/,""));
      if (!myGetter) myGetter = oGetter;
      if (!mySetter) mySetter = oSetter;
      if (myGetter) try { eval('parentNode.__defineGetter__(propName, '+ myGetter.toString() +');'); }catch(e){ Components.utils.reportError("Failed to hook property Getter: "+propName); }
      if (mySetter) try { eval('parentNode.__defineSetter__(propName, '+ mySetter.toString() +');'); }catch(e){ Components.utils.reportError("Failed to hook property Setter: "+propName); }
   }

   window.addEventListener("mousedown", function(event){
      if (event && event.button == 1) {
         window.clickState = 1;
         var ms = nsPreferences.getIntPref("mclickfocustab.timeout", 300);
         setTimeout(function(){ window.clickState = 2; }, ms);
      }
   }, true);

   window.addEventListener("mousemove", function(event){
      window.clickState = 0;
   }, true);

   hookCode("getBrowser().addTab", /return (\S+);/, "if (window.clickState == 2) { this.selectedTab = $1; } if (window.clickState > 0) { window.clickState = -1; } $&");

   hookProp(getBrowser(), "selectedTab", null, function(){
      if ((window.clickState < 0) && this.selectedTab) return val;
   });
})();

_________________
Add Bookmark Here ² | Charset Switcher | Hide Menubar | MClickFocusTab | Personal Titlebar


最後由 yuoo2k 於 2008-07-07, 00:16 編輯,總共編輯了 4 次。

回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2007-03-03, 11:17 
離線

註冊時間: 2005-06-27, 15:59
文章: 466
來自: Republic of China ( R.O.C. )
終於連上http://forums.mozillazine.org/viewtopic.php?t=397735
不過安裝了userChrome.js套件,卻不知到要把Script貼在何處

PS:相關的使用資料小弟沒找到,倒是Script看到很多。


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.1) Gecko/20070204 BonEcho/2.0.0.1 (tete009 MMX PGO)
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2007-03-03, 12:46 
離線
頭像

註冊時間: 2005-01-06, 18:58
文章: 447
過路的 寫:
終於連上http://forums.mozillazine.org/viewtopic.php?t=397735
不過安裝了userChrome.js套件,卻不知到要把Script貼在何處

PS:相關的使用資料小弟沒找到,倒是Script看到很多。


放到 userChrome.js 裡面
檔案位置在 profile 底下的 chrome 資料夾


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.1) Gecko/20061225 BonEcho/2.0.0.1 (pigfoot)
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2007-03-03, 14:37 
離線

註冊時間: 2005-06-27, 15:59
文章: 466
來自: Republic of China ( R.O.C. )
Velociraptor 寫:
放到 userChrome.js 裡面
檔案位置在 profile 底下的 chrome 資料夾

謝謝Velociraptor大的幫忙,原來是要放在這邊,感謝。 :o


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.1) Gecko/20070204 BonEcho/2.0.0.1 (tete009 MMX PGO)
 個人資料  
引用回覆  
文章發表於 : 2007-03-09, 17:44 
離線
頭像

註冊時間: 2005-08-25, 19:59
文章: 1210
來自: 幻境地帶
代碼:
(function() {
   //公用函式
   function hookCode(orgFunc, orgCode, myCode) {
      eval(orgFunc + "=" + eval(orgFunc).toString().replace(orgCode, myCode));
   }
   //鏈結有用target屬性指定目標分頁名稱時,總是在新分頁開啟該鏈結。
   hookCode("contentAreaClick", "if (linkNode) {", "$&" + (
      function() {
         if (event.button == 0 && !event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey) {
            var target = linkNode.getAttribute("target");
            if (target && !/^(_self|_parent|_top|_content|_main|_blank)$/.test(target.toLowerCase())) {
               function _existsFrameName(containerFrames, frameName) {
                  for (var i = 0; i < containerFrames.length; i++) {
                     if (containerFrames[i].name == frameName) return true;
                     if (_existsFrameName(containerFrames[i].frames, frameName)) return true;
                  }
                  return false;
               }
               if (!_existsFrameName(document.commandDispatcher.focusedWindow.top.frames, target)) {
                  openNewTabWith(linkNode.href, linkNode.ownerDocument.location.href, null, null, false);
                  return false;
               }
            }
         }
      }
   ).toString().replace(/^.*{/,"").replace(/.*}$/,""));
})();

_________________
Add Bookmark Here ² | Charset Switcher | Hide Menubar | MClickFocusTab | Personal Titlebar


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
文章發表於 : 2007-03-17, 16:37 
離線
頭像

註冊時間: 2006-10-28, 15:41
文章: 1421
來自: マカオ
修正問題: 1. 全螢幕時無效 2. 已隱藏選單會被強制顯示
部份含有 "ori-" 字眼的程式碼只適用於 HideMenubar

userChrome.css
代碼:
#toolbar-menubar:hover{visibility:visible!important}

(解決無法按下選單工具列中其他項目的問題)

userChrome.js
代碼:
var toolbar = document.getElementById("toolbar-menubar");
toolbar.collapsed = true;
toolbar.addEventListener("DOMMenuItemInactive", function(event) { //改為 toolbar-menubar, 遲開自訂工具列問題
    var menubar = event.target.parentNode;
    if (menubar.parentNode.parentNode != this) return;
    setTimeout( function() {
        var toolbar = menubar.parentNode.parentNode;
        if (toolbar.collapsed || toolbar.altKey) return;
        for (var item=menubar.firstChild; item; item=item.nextSibling) if (item.getAttribute("_moz-menuactive")) return;
        var attr = ["collapsed", "moz-collapsed"];
        for (var i=0; i<2; i++) {
            if (toolbar.getAttribute("ori-"+attr[i])) {
                toolbar.setAttribute(attr[i], true);
                toolbar.removeAttribute("ori-"+attr[i]);
            }
        }
    }, 0, menubar);
}, false);
window.addEventListener("keydown", function(event){
    if ((event.keyCode == 18) && !event.ctrlKey && !event.shiftKey && !event.metaKey)
        document.getElementById("toolbar-menubar").altKey = true;
}, true);
window.addEventListener("keyup", function(event) {
    if ((event.keyCode == 18) && !event.ctrlKey && !event.shiftKey && !event.metaKey) {
        var toolbar = document.getElementById("toolbar-menubar");
        toolbar.altKey = false;
        var attr = ["collapsed", "moz-collapsed"];
        for (var i=0; i<2; i++) {
            if (toolbar.getAttribute("ori-"+attr[i])) {
                toolbar.setAttribute(attr[i], true);
                toolbar.removeAttribute("ori-"+attr[i]);
            } else {
                if (toolbar.getAttribute(attr[i]) == "true") toolbar.setAttribute("ori-"+attr[i], true);
                toolbar.removeAttribute(attr[i]);
            }
        }
    }
}, true);
window.addEventListener("keypress", function(event) {
    var menubar = document.getElementById("main-menubar");
    var toolbar = menubar.parentNode.parentNode;
    if (event.altKey && (toolbar.collapsed || toolbar.getAttribute("moz-collapsed")) ) {
        for (var item=menubar.firstChild; item; item=item.nextSibling) {
            if ((item.localName == "menu") && (item.getAttribute("accesskey").toLowerCase() == String.fromCharCode(event.charCode)) &&
                !item.getAttribute("hidden")) // 修正能顯示已隱藏選單
            {
                toolbar.altKey = false;
                var attr = ["collapsed", "moz-collapsed"];
                for (var i=0; i<2; i++) {
                    if (toolbar.getAttribute(attr[i]) == "true") toolbar.setAttribute("ori-"+attr[i], true);
                    toolbar.removeAttribute(attr[i]);
                }
                item.lastChild.showPopup();
                break;
            }
        }
    }
}, true);

_________________
圖檔 挑選‧儲存圖片 圖檔 History Submenus Ⅱ 圖檔 Personal Menu
圖檔 Page Title in URL Bar 圖檔 Double Click Top-Left to Close


最後由 Merci chao 於 2007-04-24, 11:46 編輯,總共編輯了 2 次。

回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
 文章主題 :
文章發表於 : 2007-03-17, 17:22 
離線
[MozTW 版主群]
頭像

註冊時間: 2006-01-29, 23:45
文章: 1419
yuoo2k 寫:
userChrome.js - allows to easily customize Firefox through JavaScript.

有些小功能可以用 userChrome.js 這個小套件簡單達成,就不用多花時間特別弄一個套件出來。
Velociraptor 寫:
放到 userChrome.js 裡面
檔案位置在 profile 底下的 chrome 資料夾
Merci chao 寫:
修正問題: 1. 全螢幕時無效

全螢幕可以顯示隱藏的選單了,謝謝各位大大。

_________________
倉頡輸入法


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
 個人資料  
引用回覆  
文章發表於 : 2007-04-02, 11:08 
離線
頭像

註冊時間: 2005-08-25, 19:59
文章: 1210
來自: 幻境地帶
代碼:
(function() {
   //公用函式
   function hookCode(orgFunc, orgCode, myCode) {
      eval(orgFunc + "=" + eval(orgFunc).toString().replace(orgCode, myCode));
   }
   //自訂主選單列"歷史"下拉清單中顯示的記錄數目 (可將下兩行中的 25 改為您欲自訂的顯示數目)
   hookCode("updateGoMenu", "if (count > 10", "if (count > 25");
   hookCode("updateGoMenu", "count = 10;", "count = 25;");
})();

_________________
Add Bookmark Here ² | Charset Switcher | Hide Menubar | MClickFocusTab | Personal Titlebar


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
 個人資料  
引用回覆  
文章發表於 : 2007-12-20, 20:00 
離線

註冊時間: 2004-09-29, 04:27
文章: 419
在這裡找到的
from the excellent LouCypher (aka Zoolcar9): http://zoolcar9.lhukie.net/mozilla/userChromeJS/
該空間裡頭的「compact_menu.uc.js

代碼:
(function() {
  var compact = document.createElement("menu");
  compact.setAttribute("label", "Menu");

  var mPopup = document.createElement("menupopup");

  var menubar = document.getElementById("main-menubar");
  var menus = menubar.childNodes.length;
  for (var i = 0; i < menus; ++i) {
    mPopup.appendChild(menubar.firstChild);
  }

  compact.appendChild(mPopup);
  menubar.appendChild(compact);

})();

_________________
個人 Firefox 擴充套件收藏集


回頂端
Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.11) Gecko/20071216 BonEcho/2.0.0.11 (tete009 SSE PGO)
 個人資料  
引用回覆  
顯示文章 :  排序  
發表新文章 回覆主題  [ 36 篇文章 ]  前往頁數 123  下一頁

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 11 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章
不能 在這個版面上傳附加檔案

搜尋:
前往 :  
Powered by phpBB® Forum Software © phpBB Group
正體中文語系由 竹貓星球 維護製作
© moztw.org, Mozilla Foundation
MozTW,Mozilla 台灣社群