diff --git a/AwesomeBookmarkbar.uc.js b/AwesomeBookmarkbar.uc.js index a7ce6e9..8f7e69a 100644 --- a/AwesomeBookmarkbar.uc.js +++ b/AwesomeBookmarkbar.uc.js @@ -1,56 +1,102 @@ // ==UserScript== -// @name AwesomeBookmarkbar -// @description 智能书签工具栏 -// @homepage https://github.com/feiruo/userchromejs/ -// @author feiruo -// @charset utf-8 -// @version 0.2 -// @compatibility Firefox 24.0 -// @note 0.2 增加鼠标移到地址栏自动显示书签工具栏,移出隐藏 -// @note 点击地址栏显示书签工具栏。 -// @note 地址栏任意按键,地址栏失去焦点后自动隐藏书签工具栏。 -// @note 左键点击书签后自动隐藏书签工具栏。 +// @name AwesomeBookmarkbar.uc.js +// @description 智能书签工具栏 +// @author feiruo +// @compatibility Firefox 24.0 +// @charset UTF-8 +// @include chrome://browser/content/browser.xul +// @id [73FCA65B] +// @startup window.AwesomeBookmarkbar.init(); +// @shutdown window.AwesomeBookmarkbar.onDestroy(); +// @reviewURL http://bbs.kafan.cn/thread-1726260-1-1.html +// @homepageURL https://github.com/feiruo/userChromeJS +// @note 点击地址栏显示书签工具栏。 +// @note 地址栏任意按键,地址栏失去焦点后自动隐藏书签工具栏。 +// @note 左键点击书签后自动隐藏书签工具栏。 +// @version 0.2.1 去除鼠标移到地址栏自动显示书签工具栏 +// @version 0.2 增加鼠标移到地址栏自动显示书签工具栏,移出隐藏 // ==/UserScript== (function() { - var PTBar = document.getElementById("PersonalToolbar"); + if (window.AwesomeBookmarkbar) { + window.AwesomeBookmarkbar.onDestroy(); + delete window.AwesomeBookmarkbar; + } + + var PersonalToolbar = document.getElementById("PersonalToolbar"); + var placesCommands = document.getElementById("placesCommands"); - setToolbarVisibility(PTBar, PTBar.collapsed); + var AwesomeBookmarkbar = {}; - function hideToolbar(e) { - if (e.button == 2 || (e.button == 0 && !(e.metaKey || e.shiftKey || e.ctrlKey))) return; - PTBar.collapsed = true; - } + AwesomeBookmarkbar.init = function() { + setTimeout(function() { + setToolbarVisibility(PersonalToolbar, PersonalToolbar.collapsed); + }, 500); + setToolbarVisibility(PersonalToolbar, PersonalToolbar.collapsed); + this.addListener(this.hideToolbar, this.cHideToolbar, this.mShowToolbar, this.mHideToolbar, this.keyHide); + }; - PTBar.addEventListener("command", hideToolbar, false); - PTBar.addEventListener("click", hideToolbar, false); - placesCommands.addEventListener("command", hideToolbar, false); + AwesomeBookmarkbar.onDestroy = function() { + this.removeListener(this.hideToolbar, this.cHideToolbar, this.mShowToolbar, this.mHideToolbar, this.keyHide); + }; - gURLBar.addEventListener('click', function(e) { - if (e.button == 0) { - PTBar.collapsed = false; - } - }, false); + AwesomeBookmarkbar.addListener = function(obj, cHideToolbar, mShowToolbar, mHideToolbar, keyHide) { + PersonalToolbar.addEventListener("command", obj, false); + PersonalToolbar.addEventListener("click", obj, false); + placesCommands.addEventListener("command", obj, false); + + gURLBar.addEventListener('click', cHideToolbar, false); + + PersonalToolbar.addEventListener('mouseover', mShowToolbar, false); + + PersonalToolbar.addEventListener('mouseout', mHideToolbar, false); + + gURLBar.addEventListener('mouseout', mHideToolbar, false); - PTBar.addEventListener('mouseover', function(e) { - PTBar.setAttribute('collapsed', 'false'); - }, false); + gURLBar.addEventListener('keydown', keyHide, false); + }; - PTBar.addEventListener('mouseout', function(e) { - PTBar.setAttribute('collapsed', 'true'); - }, false); + AwesomeBookmarkbar.removeListener = function(obj, cHideToolbar, mShowToolbar, mHideToolbar, keyHide) { + PersonalToolbar.removeEventListener("command", obj, false); + PersonalToolbar.removeEventListener("click", obj, false); + placesCommands.removeEventListener("command", obj, false); - gURLBar.addEventListener('mouseover', function(e) { - PTBar.setAttribute('collapsed', 'false'); - }, false); + gURLBar.removeEventListener('click', cHideToolbar, false); - gURLBar.addEventListener('mouseout', function(e) { - PTBar.setAttribute('collapsed', 'true'); - }, false); + PersonalToolbar.removeEventListener('mouseover', mShowToolbar, false); - gURLBar.addEventListener('keydown', function(e) { + PersonalToolbar.removeEventListener('mouseout', mHideToolbar, false); + + gURLBar.removeEventListener('mouseout', mHideToolbar, false); + + gURLBar.removeEventListener('keydown', keyHide, false); + }; + + AwesomeBookmarkbar.hideToolbar = function(e) { + if (e.button == 2 || (e.button == 0 && !(e.metaKey || e.shiftKey || e.ctrlKey))) return; + PersonalToolbar.collapsed = true; + }; + + AwesomeBookmarkbar.cHideToolbar = function(e) { + if (e.button == 0) { + PersonalToolbar.collapsed = false; + } + }; + + AwesomeBookmarkbar.mShowToolbar = function(e) { + PersonalToolbar.setAttribute('collapsed', 'false'); + }; + + AwesomeBookmarkbar.mHideToolbar = function(e) { + PersonalToolbar.setAttribute('collapsed', 'true'); + }; + + AwesomeBookmarkbar.keyHide = function(e) { if (window.event ? e.keyCode : e.which) - PTBar.collapsed = true; - }, false); + PersonalToolbar.collapsed = true; + }; + + AwesomeBookmarkbar.init(); + window.AwesomeBookmarkbar = AwesomeBookmarkbar; })(); \ No newline at end of file diff --git a/Saying/Saying.uc.js b/Saying/Saying.uc.js index 961d8fb..02ffdb4 100644 --- a/Saying/Saying.uc.js +++ b/Saying/Saying.uc.js @@ -253,7 +253,7 @@ location == "chrome://browser/content/browser.xul" && (function() { Saying.lookup = function(host, type) { var site = this.SayingType if (this.Random) { - var Randoms = ['Saying', 'VeryCD', 'hitokoto']; + var Randoms = ['VeryCD', 'hitokoto']; site = Randoms[Math.floor(Math.random() * Randoms.length)]; } diff --git a/bookmarkBtn.uc.js b/bookmarkBtn.uc.js index 7ede629..cf81406 100644 --- a/bookmarkBtn.uc.js +++ b/bookmarkBtn.uc.js @@ -1,13 +1,18 @@ // ==UserScript== -// @name bookmarkBtn.uc.js -// @description 可移动书签菜单按钮 -// @namespace https://github.com/feiruo/userchromejs/ -// @author feiruo -// @include main -// @charset utf-8 -// @version 0.2 -// @note 0.2 新版添加订阅项。 -// @note 可移动书签菜单按钮。 +// @name bookmarkBtn.uc.js +// @description 可移动书签菜单按钮 +// @author feiruo +// @compatibility Firefox 16 +// @charset UTF-8 +// @include chrome://browser/content/browser.xul +// @id [E9C421E6] +// @startup window.bookmarkBtn.init(); +// @shutdown window.bookmarkBtn.onDestroy(); +// @reviewURL http://bbs.kafan.cn/thread-1666483-1-1.html +// @homepageURL https://github.com/feiruo/userChromeJS +// @note 可移动书签菜单按钮。 +// @version 0.2.1 +// @version 0.2 新版添加订阅项。 // ==/UserScript== (function() { window.bookmarkBtn = { @@ -185,9 +190,11 @@ menupopup.appendChild(menuitem); bookmarkBtn.appendChild(menupopup); - }, - } + onDestroy: function() { + $("bookmarkBtn").parentNode.removeChild($("bookmarkBtn")); + }, + }; window.bookmarkBtn.init() function $(id) { diff --git a/showFlagS/_showFlagS.js b/showFlagS/_showFlagS.js index 1f2c7f1..e2c971f 100644 --- a/showFlagS/_showFlagS.js +++ b/showFlagS/_showFlagS.js @@ -1,7 +1,7 @@ /****************************************************************************************** *这是综合设置,具体下面有解释。 *******************************************************************************************/ -var showFlagsPer = { +var Perfs = { //显示国旗图标位置 如:urlbar-icons、identity-box、TabsToolbar、nav-bar-customization-target等等 showLocationPos: "identity-box", @@ -23,7 +23,7 @@ var showFlagsPer = { /****************************************************************************************** *这里是设置文字显示的,可以自定义多个,可以根据需要截取,只支持函数操作。 *******************************************************************************************/ -var showFlagStipSet = [{ +var ServerInfo = [{ label: "服务器:", words: "Server" }, { @@ -82,7 +82,7 @@ showFlagS.command('Action','http://ping.chinaz.com/', 'host', 'IP', null,'but') showFlagS.command("Edit", "文件路径,支持相对路径") showFlagS.command("Copy", "函数或者字符串") *******************************************************************************************/ -var showFlagSmenu = [{ +var Menus = [{ label: "地址IP", image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAt0lEQVQ4jcXTsWoCQRSF4Q8SsNEitUnhM6RQUtjb+xixTRHIG+SFks7GVxBksbBPGVjWQpsjSNhdXUjIhb+4c5l/mMMMv1g93IfeWf8Qhhi0CcYowmMosAtbfGCO2zrBFGV4CiUOP/iK5GrBHu94wTqSz7rrNAnKzOAtgm0yuUpQ4RkzLCNY4a5LBlU4ZG3RJYOT4BsbvKLfRVDlxAlGuKnb3CY4D7G1/l/Q9JSLzC5W02c69X9TR6H4UVapsaP+AAAAAElFTkSuQmCC", child: [{ @@ -448,54 +448,56 @@ var showFlagSmenu = [{ image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAm0lEQVQ4jbWTUQrDIBBEH9QcokjZe+T+ieQaJXiKfvSjIyyJRmzpwHzsuo47qwJMgIlBvIpPMGAFEnAXUyOOLYEEbG7D1oirAsEV3sQoltivdwWO6Ap4C7UWIwMzqBUY8BTtGwvDAmWIBjyAGcjirJypJhwt+HvfdWoGXmJWbgeW0tHPAoHzvQ9Z6KE7xL8LRD5+FxoPqYfL7/wGEBc4QhYRpZIAAAAASUVORK5CYII=" }]; /****************************************************************************************************************** - *这里是查询源设置,taobao为脚本内置,可以自行按照示例添加,不限定于IP,可以是其他相关的API,只要是你想要显示的都可以 + *这里是查询源设置,只支持"GET"方式获取,taobao为脚本内置,可以自行按照示例添加,不限定于IP,可以是其他相关的API,只要是你想要显示的都可以 *******************************************************************************************************************/ -var showFlagSsiteSource = [{ +var MyInfo = { //查询自己IP信息的接口,可以去掉或者改函数名字去掉功能 + inquireAPI: "http://whois.pconline.com.cn/", //查询接口API + //regulation是截取函数,docum是一个XMLHttpRequest()的req.responseText,(具体可以百度 XMLHttpRequest())。传回的obj为最终要显示的结果和样式等 + regulation: function(docum) { + docum = docum.substring(docum.indexOf("位置")); + docum = docum.substring(0, docum.indexOf("

接口列表")); + + var addr = docum.substring(3, docum.indexOf("\n")); + + var ip = docum.substring(docum.indexOf("为:")); + ip = ip.substring(2, ip.indexOf("\n")); + + var RemoteAddr = docum.substring(docum.indexOf("RemoteAddr")); + RemoteAddr = RemoteAddr.substring(11, RemoteAddr.indexOf("
")); + + var MyInfos = "我的IP:" + ip + '\n' + "我的地址:" + addr + '\n' + "RemoteAddr:" + RemoteAddr; + return MyInfos; + } +}; + +var SourceAPI = [{ label: "纯真 查询源", //菜单中显示的文字 id: "CZ", //必须设定一个ID,以便脚本读取 - type: "GET", //获取类型 - inquireAPI: "http://www.cz88.net/ip/index.aspx?ip=", //查询接口API - //regulation是截取函数,返回“null”的时候便使用备用查询源(淘宝); - //docum是一个XMLHttpRequest()的req.responseText,(具体可以百度 XMLHttpRequest())。传回的obj为最终要显示的结果和样式等 + inquireAPI: "http://www.cz88.net/ip/index.aspx?ip=", + //返回“null”的时候便使用备用查询源(淘宝); regulation: function(docum) { var s_local, myip, myAddr; var addr_pos = docum.indexOf("AddrMessage"); s_local = docum.substring(addr_pos + 13); s_local = s_local.substring(0, s_local.indexOf("<")); - var myip_pos = docum.indexOf("cz_ip"); - myip = docum.substring(myip_pos + 7); - myip = myip.substring(0, myip.indexOf("<")); - var myAddr_pos = docum.indexOf("cz_addr"); - myAddr = docum.substring(myAddr_pos + 9); - myAddr = myAddr.substring(0, myAddr.indexOf("<")); s_local = s_local.replace(/ +CZ88.NET ?/g, ""); if (s_local) { - if (myip) s_local = s_local + '\n' + '我的IP:' + myip; - if (myAddr) s_local = s_local + '\n' + '我的地址:' + myAddr; - var obj = { - Site: s_local - }; - return obj; + return s_local; } else return null; } }, { label: "太平洋电脑", id: "pconline", - type: "GET", inquireAPI: "http://whois.pconline.com.cn/ip.jsp?ip=", regulation: function(docum) { var docum = docum.replace(/\n/ig, ""); - var obj = { - Site: docum - }; if (docum) { - return obj; + return docum; } else return null; } }, { - label: "MyIP 查询源", + label: "MyIP查询源", id: "myip", - type: "GET", inquireAPI: "http://www.myip.cn/", regulation: function(docum) { var myip_addr, myip_flag; @@ -509,16 +511,12 @@ var showFlagSsiteSource = [{ if (myip_addr.indexOf("\r\n\t\t") !== -1) myip_addr = myip_addr.substring(0, myip_addr.indexOf("\r\n\t\t")); if (myip_addr) { - var obj = { - Site: myip_addr - }; - return obj; + return myip_addr; } else return null; } }, { label: "新浪 查询源", id: "sina", - type: "GET", inquireAPI: "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=", regulation: function(docum) { var responseObj = JSON.parse(docum); @@ -527,25 +525,18 @@ var showFlagSsiteSource = [{ var addr = responseObj.country + responseObj.province + responseObj.city + responseObj.district + '\n' + responseObj.isp + responseObj.type + responseObj.desc; else var addr = responseObj.country + responseObj.province + responseObj.city + responseObj.district; - var obj = { - Site: addr - }; - return obj; + return addr; } else return null; } }, { - label: "波士顿大学源", + label: "波士顿大学", id: "CZedu", - type: "GET", inquireAPI: "http://phyxt8.bu.edu/iptool/qqwry.php?ip=", regulation: function(docum) { var s_local = docum; s_local = s_local.replace(/ +CZ88.NET ?/g, ""); - var obj = { - Site: s_local - }; if (s_local) { - return obj; + return s_local; } else return null; } }, ] \ No newline at end of file diff --git a/showFlagS/showFlagS.uc.js b/showFlagS/showFlagS.uc.js index 38f5869..68e2c84 100644 --- a/showFlagS/showFlagS.uc.js +++ b/showFlagS/showFlagS.uc.js @@ -1,5 +1,5 @@ // ==UserScript== -// @name showFlagS +// @name showFlagS.uc.js // @description 显示国旗与IP // @author ywzhaiqi、feiruo // @compatibility Firefox 16 @@ -51,9 +51,10 @@ location == "chrome://browser/content/browser.xul" && (function() { BAK_FLAG_PATH: 'http://www.razerzone.com/asset/images/icons/flags/', //网络图标地址 http://www.1108.hk/images/ext/ http://www.myip.cn/images/country_icons/ isFirstRun: true, apiSite: null, - siteQueue: 0, - siteApi: [], - siteThx: [], + siteQueue: null, + siteApi: null, + siteThx: null, + MyInfoThx: null, dnsCache: [], isReqHash: [], isReqHash_tooltip: [], @@ -100,9 +101,9 @@ location == "chrome://browser/content/browser.xul" && (function() { }; showFlagS.uninit = function() { - this.removeMenu(this.showFlagSmenu); + this.removeMenu(this.Menus); $("showFlagS-popup").parentNode.removeChild($("showFlagS-popup")); - if (this.showFlagsPer.showLocationPos == "identity-box") + if (this.Perfs.showLocationPos == "identity-box") $("page-proxy-favicon").style.visibility = ""; }; @@ -162,15 +163,16 @@ location == "chrome://browser/content/browser.xul" && (function() { return; } - this.removeMenu(this.showFlagSmenu); + this.removeMenu(this.Menus); - this.showFlagsPer = sandbox.showFlagsPer; - this.showFlagSmenu = sandbox.showFlagSmenu; - this.showFlagStipSet = sandbox.showFlagStipSet; - this.showFlagSsiteSource = sandbox.showFlagSsiteSource; + this.Perfs = sandbox.Perfs; + this.Menus = sandbox.Menus; + this.ServerInfo = sandbox.ServerInfo; + this.SourceAPI = sandbox.SourceAPI; + this.MyInfo = sandbox.MyInfo; this.getPrefs(); - new this.buildIconMenu(this.showFlagSmenu, this.showFlagSsiteSource, this.showFlagsPer); + new this.buildIconMenu(this.Menus, this.SourceAPI, this.Perfs); this.setPerfs(); if (isAlert) this.alert('配置已经重新载入'); @@ -210,13 +212,9 @@ location == "chrome://browser/content/browser.xul" && (function() { this._prefs.QueryInterface(Components.interfaces.nsIPrefBranch2); if (!this._prefs.prefHasUserValue("SourceSite") || this._prefs.getPrefType("SourceSite") != Ci.nsIPrefBranch.PREF_STRING) - this._prefs.setCharPref("SourceSite", (this.showFlagSsiteSource ? (this.showFlagSsiteSource[0] ? this.showFlagSsiteSource[0].id : "taobao") : "taobao")); - - if (!this._prefs.prefHasUserValue("isExternalComparison") || this._prefs.getPrefType("isExternalComparison") != Ci.nsIPrefBranch.PREF_BOOL) - this._prefs.setBoolPref("isExternalComparison", this.isExternalComparison) + this._prefs.setCharPref("SourceSite", (this.SourceAPI ? (this.SourceAPI[0] ? this.SourceAPI[0].id : "taobao") : "taobao")); this.apiSite = this._prefs.getCharPref("SourceSite"); - this.isExternalComparison = this._prefs.getBoolPref("isExternalComparison"); }; showFlagS.setPerfs = function(tyep, val) { @@ -225,30 +223,24 @@ location == "chrome://browser/content/browser.xul" && (function() { this._prefs.setCharPref("SourceSite", this.apiSite); $("showFlagS-apiSite-" + this.apiSite).setAttribute('checked', true); } - if (tyep == "ExternalC") { - this.isExternalComparison = !this.isExternalComparison; - this._prefs.setBoolPref("isExternalComparison", this.isExternalComparison); - $("showFlagS-set-externalComparison").setAttribute('checked', this.isExternalComparison); - } - for (var i = 0; i < this.showFlagSsiteSource.length; i++) { - if (this.showFlagSsiteSource[i].id == this.apiSite) { + for (var i = 0; i < this.SourceAPI.length; i++) { + if (this.SourceAPI[i].id == this.apiSite) { this.siteQueue = i; - this.siteApi = this.showFlagSsiteSource[i].inquireAPI; + this.siteApi = this.SourceAPI[i].inquireAPI; } } + this.MyInfoThx = Cc["@mozilla.org/network/effective-tld-service;1"].getService(Ci.nsIEffectiveTLDService).getBaseDomain(makeURI(this.MyInfo.inquireAPI)); this.siteThx = Cc["@mozilla.org/network/effective-tld-service;1"].getService(Ci.nsIEffectiveTLDService).getBaseDomain(makeURI(this.siteApi)); this.onLocationChange(true); }; /*****************************************************************************************/ - showFlagS.showDetails = function(isTell) {}; - showFlagS.onLocationChange = function(forceRefresh) { if (forceRefresh) { this.forceRefresh = true; } try { var aLocation = this.contentDoc.location; - if (this.showFlagsPer.showLocationPos == 'identity-box') { + if (this.Perfs.showLocationPos == 'identity-box') { if ((aLocation.protocol !== "about:") && (aLocation.protocol !== "chrome:")) $('page-proxy-favicon').style.visibility = 'collapse'; else @@ -256,19 +248,19 @@ location == "chrome://browser/content/browser.xul" && (function() { this.icon.hidden = ((aLocation.protocol == "about:") || (aLocation.protocol == "chrome:")); } if (aLocation && /file/.test(aLocation.protocol)) { - this.icon.src = this.icon.image = this.showFlagsPer.File_Flag; + this.icon.src = this.icon.image = this.Perfs.File_Flag; this.icon.tooltipText = '本地文件' + "\n" + aLocation; return; } if (aLocation && aLocation.hostname == "localhost") { var obj = {}; - this.icon.src = this.icon.image = this.showFlagsPer.LocahHost_Flag; + this.icon.src = this.icon.image = this.Perfs.LocahHost_Flag; obj.locInfo = '回送地址,本机服务器'; new showFlagS.updateTooltipText("127.0.0.1", aLocation.host, obj); return; } if (aLocation && /data/.test(aLocation.protocol)) { - this.icon.src = this.icon.image = this.showFlagsPer.File_Flag; + this.icon.src = this.icon.image = this.Perfs.File_Flag; this.icon.tooltipText = 'Base64编码文件'; return; } @@ -309,7 +301,7 @@ location == "chrome://browser/content/browser.xul" && (function() { showFlagS.resetState = function() { this.icon.src = this.icon.image = this.DEFAULT_Flag; this.icon.tooltipText = ''; - if (this.showFlagsPer.showLocationPos == 'identity-box') { + if (this.Perfs.showLocationPos == 'identity-box') { this.icon.hidden = true; $('page-proxy-favicon').style.visibility = 'visible'; } @@ -326,22 +318,24 @@ location == "chrome://browser/content/browser.xul" && (function() { return; } if (ip == "127.0.0.1" || ip == "::1") { - var obj = {}; - obj.locInfo = '回送地址,本机服务器'; - new showFlagS.updateTooltipText(ip, host, obj); - self.icon.src = self.icon.image = self.showFlagsPer.LocahHost_Flag; - if (self.showFlagsPer.showLocationPos == 'identity-box') { + self.showFlagTooltipHash[host] = {} + self.showFlagTooltipHash[host].locInfo = '回送地址,本机服务器'; + self.showFlagTooltipHash[host].serverInfo = this.serverInfoTip(); + new showFlagS.updateTooltipText(ip, host, self.showFlagTooltipHash[host]); + self.icon.src = self.icon.image = self.Perfs.LocahHost_Flag; + if (self.Perfs.showLocationPos == 'identity-box') { $('page-proxy-favicon').style.visibility = 'collapse'; self.icon.hidden = false } return; } if (/^192.168.|169.254./.test(ip)) { - var obj = {}; - obj.locInfo = '本地局域网服务器'; - new showFlagS.updateTooltipText(ip, host, obj); - self.icon.src = self.icon.image = self.showFlagsPer.LAN_Flag; - if (self.showFlagsPer.showLocationPos == 'identity-box') { + self.showFlagTooltipHash[host] = {} + self.showFlagTooltipHash[host].locInfo = '本地局域网服务器'; + self.showFlagTooltipHash[host].serverInfo = this.serverInfoTip(); + new showFlagS.updateTooltipText(ip, host, self.showFlagTooltipHash[host]); + self.icon.src = self.icon.image = self.Perfs.LAN_Flag; + if (self.Perfs.showLocationPos == 'identity-box') { $('page-proxy-favicon').style.visibility = 'collapse'; self.icon.hidden = false } @@ -373,11 +367,56 @@ location == "chrome://browser/content/browser.xul" && (function() { } if (checkCache && self.isReqHash_tooltip[host]) return; self.isReqHash_tooltip[host] = true; + self.showFlagTooltipHash[host] = {}; + self.showFlagTooltipHash[host].serverInfo = this.serverInfoTip(); + this.lookup_Myinfo(self.MyInfo.inquireAPI, host); if (self.apiSite == 'taobao') self.lookupIP_taobao(ip, host); else new self.lookupIP_Info(ip, host, self.siteApi, self.siteQueue); }, + serverInfoTip: function() { + var sTip = []; + for (var i = 0; i < showFlagS.ServerInfo.length; i++) { + var tip = this.getServInformation(showFlagS.ServerInfo[i].words); + if (showFlagS.ServerInfo[i].regx) tip = showFlagS.ServerInfo[i].regx(tip); + + if (tip !== '未知类型') + sTip.push(showFlagS.ServerInfo[i].label + tip); + } + return sTip.join('\n'); + }, + getServInformation: function(words) { + var word; + try { + word = gBrowser.mCurrentBrowser.webNavigation.currentDocumentChannel.QueryInterface(Ci.nsIHttpChannel).getResponseHeader(words).split("\n", 1)[0]; + } catch (e) {} + return word || '未知类型'; + }, + lookup_Myinfo: function(api, host) { + var self = showFlagS; + var req = new XMLHttpRequest(); + req.open("GET", api, true); + req.send(null); + var onerror = function() { + self.showFlagTooltipHash[host].MyInfos = "查询失败"; + }; + req.onerror = onerror; + req.timeout = self.Perfs.Inquiry_Delay; + req.ontimeout = onerror; + req.onload = function() { + if (req.status == 200) { + var obj = self.MyInfo.regulation(req.responseText); + if (obj) { + self.showFlagTooltipHash[host].MyInfos = obj; + } else { + onerror(); + } + } else { + onerror(); + } + }; + } }; showFlagS.updateIcon = function(host, countryCode, countryName) { @@ -389,7 +428,7 @@ location == "chrome://browser/content/browser.xul" && (function() { if (host == self.contentDoc.location.host) { self.icon.hidden = false; var aLocation = self.contentDoc.location; - if (showFlagS.showFlagsPer.showLocationPos == 'identity-box') { + if (showFlagS.Perfs.showLocationPos == 'identity-box') { if (aLocation.protocol !== 'https:') $('page-proxy-favicon').style.visibility = 'collapse'; else @@ -397,7 +436,7 @@ location == "chrome://browser/content/browser.xul" && (function() { } var src; if (countryCode === 'iana') { - src = self.showFlagsPer.Unknown_Flag; + src = self.Perfs.Unknown_Flag; } else { src = window.CountryFlags ? (this.getFlagFoxIconPath(countryCode) || CountryFlags[countryCode]) : this.getFlagFoxIconPath(countryCode); if (!src && window.CountryFlags && countryName) { @@ -407,9 +446,9 @@ location == "chrome://browser/content/browser.xul" && (function() { self.showFlagHash[host] = contryCode; } } - src = src || (self.BAK_FLAG_PATH + countryCode + ".gif") || self.showFlagsPer.Unknown_Flag; + src = src || (self.BAK_FLAG_PATH + countryCode + ".gif") || self.Perfs.Unknown_Flag; - if (showFlagS.showFlagsPer.showLocationPos == 'identity-box') { + if (showFlagS.Perfs.showLocationPos == 'identity-box') { if (src) $('page-proxy-favicon').style.visibility = 'collapse'; else { @@ -450,42 +489,26 @@ location == "chrome://browser/content/browser.xul" && (function() { obj || (obj = {}); tooltipArr.push("域名:" + host); tooltipArr.push("网站IP:" + ip); - var serverInfo = this.serverInfoTip(); - if (serverInfo !== "") - tooltipArr.push(serverInfo); + + if (obj.serverInfo !== "") + tooltipArr.push(obj.serverInfo); if (obj.locInfo) tooltipArr.push(obj.locInfo); - if (obj.Site) { + if (obj.Site) tooltipArr.push(obj.Site); - tooltipArr.push('感谢:' + showFlagS.siteThx); - } if (obj.taobao) { tooltipArr.push(obj.taobao); - tooltipArr.push('感谢 淘宝(www.taobao.com)') + showFlagS.siteThx = "淘宝(www.taobao.com)"; } - showFlagS.icon.tooltipText = tooltipArr.join('\n'); - }, - serverInfoTip: function() { - var sTip = []; - for (var i = 0; i < showFlagS.showFlagStipSet.length; i++) { - var tip = this.getServInformation(showFlagS.showFlagStipSet[i].words); - if (showFlagS.showFlagStipSet[i].regx) tip = showFlagS.showFlagStipSet[i].regx(tip); + if (obj.MyInfos && obj.MyInfos !== "查询失败") + tooltipArr.push(obj.MyInfos); - if (tip !== '未知类型') - sTip.push(showFlagS.showFlagStipSet[i].label + tip); - } - return sTip.join('\n'); - }, - getServInformation: function(words) { - var word; - try { - word = gBrowser.mCurrentBrowser.webNavigation.currentDocumentChannel.QueryInterface(Ci.nsIHttpChannel).getResponseHeader(words).split("\n", 1)[0]; - } catch (e) {} - return word || '未知类型'; + tooltipArr.push('感谢:' + showFlagS.siteThx + '、' + showFlagS.MyInfoThx); + showFlagS.icon.tooltipText = tooltipArr.join('\n'); }, }; @@ -502,14 +525,14 @@ location == "chrome://browser/content/browser.xul" && (function() { self.lookupIP_taobao(ip, host, "other"); }; req.onerror = onerror; - req.timeout = self.showFlagsPer.Inquiry_Delay; + req.timeout = self.Perfs.Inquiry_Delay; req.ontimeout = onerror; req.onload = function() { if (req.status == 200) { - var obj = self.showFlagSsiteSource[i].regulation(req.responseText); + var obj = self.SourceAPI[i].regulation(req.responseText); if (obj) { - self.showFlagTooltipHash[host] = obj; - new self.updateTooltipText(ip, host, obj); + self.showFlagTooltipHash[host].Site = obj; + new self.updateTooltipText(ip, host, self.showFlagTooltipHash[host]); } else { onerror(); } @@ -527,12 +550,12 @@ location == "chrome://browser/content/browser.xul" && (function() { req.open("GET", 'http://ip.taobao.com/service/getIpInfo.php?ip=' + ip, true); req.send(null); var onerror = function() { - self.icon.src = self.showFlagsPer.Unknown_Flag; + self.icon.src = self.Perfs.Unknown_Flag; if (other || self.apiSite == 'taobao') self.icon.tooltipText = '无法查询,请刷新!'; }; req.onerror = onerror; - req.timeout = self.showFlagsPer.Inquiry_Delay; + req.timeout = self.Perfs.Inquiry_Delay; req.ontimeout = onerror; req.onload = function() { if (req.status == 200) { @@ -546,8 +569,8 @@ location == "chrome://browser/content/browser.xul" && (function() { taobao: addr }; if (other || self.apiSite == 'taobao') { - self.showFlagTooltipHash[host] = obj; - new self.updateTooltipText(ip, host, obj); + self.showFlagTooltipHash[host].taobao = obj; + new self.updateTooltipText(ip, host, self.showFlagTooltipHash[host]); } self.showFlagHash[host] = country_id; new self.updateIcon(host, country_id, responseObj.data.country); @@ -557,7 +580,7 @@ location == "chrome://browser/content/browser.xul" && (function() { } }; }; - + /*****************************************************************************************/ showFlagS.alert = function(aString, aTitle) { Cc['@mozilla.org/alerts-service;1'].getService(Ci.nsIAlertsService).showAlertNotification("", aTitle || "showFlagS", aString, false, "", null); }; @@ -787,7 +810,6 @@ location == "chrome://browser/content/browser.xul" && (function() { }, false); //$("showFlagS-popup").setAttribute('position', iconPref.iconMenuPosition); - //$("showFlagS-set-externalComparison").setAttribute('checked', showFlagS.isExternalComparison); $("showFlagS-apiSite-" + showFlagS.apiSite).setAttribute('checked', true); }, buildSiteMenu: function(siteSource) { diff --git a/starClickMod.uc.js b/starClickMod.uc.js index 7067602..3abad98 100644 --- a/starClickMod.uc.js +++ b/starClickMod.uc.js @@ -1,39 +1,35 @@ // ==UserScript== -// @name star Click Mod -// @description 多功能收藏按钮 -// @homepage https://github.com/feiruo/userchromejs/ -// @author feiruo -// @include chrome://browser/content/browser.xul -// @charset utf-8 -// @version 1.8 -// @note 参考star Click(http://g.mozest.com/viewthread.php?tid=41377) -// @note 为编辑面板增加更多功能 -// @note 右键删除当前书签 -// @note 1.8 修正重启后可能按键失效的问题。 -// @note 1.7 修复右键报错,Australis重整UI后失效问题,增加 中键 打开/隐藏 书签侧栏。 -// @note 1.6 Australis 添加书签按钮移动至地址栏。 -// @note 1.5 支持 Nightly Holly. -// @note 1.4 支持 firefox 24 以下版本. -// @note 1.3 修复了可能出现的文件夹列表不能自动展开和获取上次文件夹的问题. -// @note 1.2 修正因 firefox 26 添加了 bookmarks-menu-button 导致的判断出错. -// @note 1.1 修正因 Nightly Australis 没有删除 star-button 导致的判断出错. -// @note 1.0 +// @name starClickMod.uc.js +// @description 多功能收藏按钮 +// @author feiruo +// @compatibility Firefox 16 +// @charset UTF-8 +// @include chrome://browser/content/browser.xul +// @id [77DDE674] +// @reviewURL http://bbs.kafan.cn/thread-1657336-1-1.html +// @homepageURL https://github.com/feiruo/userChromeJS +// @note 参考star Click(http://g.mozest.com/viewthread.php?tid=41377) +// @note 为编辑面板增加更多功能 +// @note 左键弹出书签添加编辑面板,中键打开书签侧栏,右键删除当前书签 +// @version 1.8.1 去除Holly,删掉多余的动作(修改五角星位置等)。 +// @version 1.8 修正重启后可能按键失效的问题。 +// @version 1.7 修复右键报错,Australis重整UI后失效问题,增加 中键 打开/隐藏 书签侧栏。 +// @version 1.6 Australis 添加书签按钮移动至地址栏。 +// @version 1.5 支持 Nightly Holly. +// @version 1.4 支持 firefox 24 以下版本. +// @version 1.3 修复了可能出现的文件夹列表不能自动展开和获取上次文件夹的问题. +// @version 1.2 修正因 firefox 26 添加了 bookmarks-menu-button 导致的判断出错. +// @version 1.1 修正因 Nightly Australis 没有删除 star-button 导致的判断出错. // ==/UserScript== (function() { if (location == "chrome://browser/content/browser.xul") { - //是否移动添加书签五角星到地址栏 - var olduimod = false; - - //是否隐藏dropmarker,配合bookmarkBtn.uc.js效果更佳 - var hidedropmarker = false; - var version = Services.appinfo.version.split(".")[0]; + window.starClick = { init: function() { this.bookmarkPageU(); this.lastfolder(); this.clickStar(); - this.resizeUI(); }, bookmarkPageU: function() { @@ -41,7 +37,6 @@ eval("PlacesCommandHook.bookmarkPage=function PCH_bookmarkPage(aBrowser, aParent, aShowEditUI) {" + bookmarkPage + "}"); eval("StarUI._doShowEditBookmarkPanel=" + StarUI._doShowEditBookmarkPanel.toString().replace(/hiddenRows: \[[^]*\]/, "hiddenRows: []").replace(/}$/, "setTimeout(function(){ gEditItemOverlay.toggleFolderTreeVisibility();document.getAnonymousNodes(document.getElementById('editBMPanel_tagsSelector'))[1].lastChild.style.display = 'inline-block'; document.getElementById('editBMPanel_tagsSelector').style.cssText = 'max-height:50px !important; width:300px !important'; document.getElementById('editBMPanel_folderTree').style.cssText = 'min-height:200px !important; max-width:300px !important';document.getElementById('editBookmarkPanel').style.maxHeight='800px'}, 0); $&")); eval("StarUI.handleEvent=" + StarUI.handleEvent.toString().replace('aEvent.target.className == "expander-up" ||', '$& aEvent.target.id == "editBMPanel_descriptionField" ||')); - }, lastfolder: function() { @@ -59,8 +54,7 @@ } _recentFolders.sort(function(a, b) { if (b.lastUsed < a.lastUsed) return -1; - if (b.lastUsed > - a.lastUsed) return 1; + if (b.lastUsed > a.lastUsed) return 1; return 0; }); return _recentFolders.length > 0 ? _recentFolders[0].folderId : PlacesUtils.unfiledBookmarksFolderId; @@ -68,7 +62,7 @@ }, clickStar: function() { - if (version < 28) { + if (version < 29) { var onClick = function(e) { if (e.button == 0 && !this._pendingStmt) { PlacesCommandHook.bookmarkCurrentPage(true); @@ -100,16 +94,8 @@ }, false); })(document); } else { - var holly = false; - try { - var holly = document.getElementById('appmenu_about').label; - } catch (e) {} - if (holly) - var starbutton = document.getElementById('star-button'); - else { - var bookmarksMenuBtn = document.getElementById('bookmarks-menu-button'); - var starbutton = document.getAnonymousNodes(bookmarksMenuBtn)[1]; - } + var bookmarksMenuBtn = document.getElementById('bookmarks-menu-button'); + var starbutton = document.getAnonymousNodes(bookmarksMenuBtn)[1]; starbutton.addEventListener("click", function(e) { if (e.button == 0) { PlacesCommandHook.bookmarkCurrentPage(true); @@ -130,45 +116,6 @@ }, false); } }, - - resizeUI: function() { - if (version > 28) { - //隐藏dropmarker配合bookmarkBtn.uc.js效果更佳 - if (hidedropmarker) { - var cssStr = ('\ - #bookmarks-menu-button > dropmarker {display: none !important;}\ - '); - var style = document.createProcessingInstruction('xml-stylesheet', 'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(cssStr) + '"'); - document.insertBefore(style, document.documentElement); - } - - //Australis移动添加书签五角星到地址栏 - if (olduimod) { - var urlIcon = document.getElementById('urlbar-icons'); - var starbutton = document.getElementById('bookmarks-menu-button'); - urlIcon.appendChild(starbutton); - var menupopup = starbutton.firstChild; - var cssStr = ('\ - #bookmarks-menu-button {\ - list-style-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAtCAYAAABxsjF3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmV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ZR9wriA+sKNXhr9fMqVmZx7sOsCVByUiQkSnAfwE48TIQfzi8wCMuZLLnP9QkFF1DMzKVSkowey8In04GYC4YydgdAlNY4ALipyn8HcQh+vKK9sRvVU1akqHv+hhcuNAXi6ctp174UVc70cTu7RvBmZezuEc6TGc0J+9PzcdWqd0X9x384Ul7ftF1jO3u4Tc7h+ZmJk51njx6YHEpuN2Rb04uc/4jwACnFx3FfyjlHQAAAABJRU5ErkJggg==") !important;\ - -moz-image-region: rect(0, 15px, 15px, 0) !important; margin-bottom: 1px !important;\ - }\ - #bookmarks-menu-button:not([starred]):hover {-moz-image-region: rect(15px, 15px, 30px, 0) !important;}\ - #bookmarks-menu-button[starred] {-moz-image-region: rect(30px, 15px, 45px, 0) !important;}\ - #bookmarks-menu-button >toolbarbutton,\ - #bookmarks-menu-button >toolbarbutton .toolbarbutton-icon{\ - -moz-appearance:none!important;\ - border:none!important;\ - box-shadow:none!important;\ - background:none!important;\ - margin:0!important;\ - }\ - '); - var style = document.createProcessingInstruction('xml-stylesheet', 'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(cssStr) + '"'); - document.insertBefore(style, document.documentElement); - } - } - }, }; window.starClick.init(); setTimeout(starClick.clickStar, 500);