阅读:1258回复:1
页面双击左键关闭页面可以加个开关吗
// ==UserScript==
// @name closeTabOnDblClick.uc.js // @include main // @compatibility Firefox 3.0 // @author Cye3s // @version LastMod 2008-08-30 10:38 // ==/UserScript== gBrowser.mPanelContainer.addEventListener("dblclick", function(aEvent){ if (aEvent.ctrlKey) return; aEvent.stopPropagation(); gBrowser.removeCurrentTab(); }, false); AutoCopyBtn.uc之前这个自动复制在地址栏有一个开关的可否同样搞一个 |
|
1楼#
发布于:2017-07-24 17:57
// ==UserScript==
// @name autoCopyBtn.uc.js // @namespace ithinc#mozine.cn // @description 可控自动复制,地址栏按钮版 // @include main // @compatibility Firefox 3.0.x // @author ithinc, iwo // @charset UTF-8 // @version LastMod 2014.04.12 by defpt // @Note https://github.com/defpt/userChromeJs/tree/master/autoCopy // @Note https://g.mozest.com/redirect.php?goto=findpost&pid=299093&ptid=42980 // ==/UserScript== (function () { var lastSelection = ""; var autocopyImages = ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsSAAALEgHS3X78AAADtElEQVQ4jQXBfWjUdRwH8Pfn+/ves7u73blH3E031x6c2zQcw52NQJGIsakVVNiDsyAJyQYFZaBZYQWB2T8FCTIZQkJIjdYDoa2ZtIfMsbbmRpvNbXe3dbvb3e9+9/v9vt9vrxct1NeTyueVMxzeHOruttfdnnUjm6ZKj1Mt/jaK5Qdr8JGNi/VV21ssVLYWVm8+WX3yx/eS15Idvd3gcduGIIIVj58r1LMFfc7Qmwtr8xVv1zTpk4+9vOlu7cGK1MpcJDjxU0fjwKU9ZduM4urI0hdZQb1QKsNJKWUTRd2gZ8QvQ/7GQ8dbJupeC51gBdwhZIBNJZzF6ys4MHwD1alVWTyzgcPlg10VLVX9IMdNDgB5KbVCt8vjfLCodv1wrWHjlb1khiT8Xk05Mmnb99EFVTd/m7n9YWamk6rtj+tF0mjoUJ3tQ0wRaR7Im1Nw9c75Cqlwckx0fXdePPuwSx4sz2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var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); if (!prefs.getPrefType("userChrome.autocopy.autocopyState")) prefs.setIntPref("userChrome.autocopy.autocopyState", 1); function autocopyStart(e) { lastSelection = getBrowserSelection(); } function autocopyStop(e) { var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); var autocopyState = prefs.getIntPref("userChrome.autocopy.autocopyState"); var selection = getBrowserSelection(); //增加判断是否在输入框或按下功能键 var exceptTarget = (e.target.nodeName == "TEXTAREA" || e.target.type == "textarea" || e.target.type == "text" || e.target.type == "password" || e.target.type == "email"); var exceptoriginalTarget = (!e.originalTarget.ownerDocument || e.originalTarget.ownerDocument.designMode == "off" || e.originalTarget.ownerDocument.designMode == "undefined"); var exceptAlternativeKey = (e.ctrlKey || e.altKey); var except = (exceptTarget && exceptoriginalTarget && !exceptAlternativeKey); if (autocopyState > 0 && selection && selection != lastSelection && !except) { goDoCommand('cmd_copy'); } } gBrowser.mPanelContainer.addEventListener("mousedown", autocopyStart, false); gBrowser.mPanelContainer.addEventListener("mouseup", autocopyStop, false); var statusbarpanel = document.getElementById("urlbar-icons").appendChild(document.createElement("statusbarpanel")); ; statusbarpanel.setAttribute("id", "autocopy-statusbarpanel"); statusbarpanel.setAttribute("class", "statusbarpanel-iconic"); statusbarpanel.setAttribute("onclick", '\ if(event.button==0) {\ var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);\ var autocopyState = prefs.getIntPref("userChrome.autocopy.autocopyState");\ prefs.setIntPref("userChrome.autocopy.autocopyState", (autocopyState+1)%2);\ }\ '); function refreshStatus() { var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); var autocopyState = prefs.getIntPref("userChrome.autocopy.autocopyState"); var statusbarpanel = document.getElementById("autocopy-statusbarpanel"); statusbarpanel.setAttribute("src", autocopyImages[autocopyState % 2]); statusbarpanel.tooltipText = autocopyTooltips[autocopyState % 2]; } refreshStatus(); var observer = { observe : function (subject, topic, prefName) { refreshStatus(); } }; prefs.QueryInterface(Ci.nsIPrefBranchInternal).addObserver("userChrome.autocopy.autocopyState", observer, false); })(); |
|