From b1bf2ae4d025f2650cf8b9ddb1fe8f97d5bc6c2c Mon Sep 17 00:00:00 2001 From: feiruo Date: Wed, 29 Jan 2014 14:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=B6=E8=97=8F=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=A7=BB=E5=8A=A8=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- starClickMod.uc.js | 51 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/starClickMod.uc.js b/starClickMod.uc.js index b7188ea..3fabec8 100644 --- a/starClickMod.uc.js +++ b/starClickMod.uc.js @@ -5,10 +5,11 @@ // @author feiruo // @include chrome://browser/content/browser.xul // @charset utf-8 -// @version 1.5 +// @version 1.6 // @note 参考star Click(http://g.mozest.com/viewthread.php?tid=41377) // @note 为编辑面板增加更多功能 // @note 右键删除当前书签 +// @note 1.6 Australis 添加书签按钮移动至地址栏。 // @note 1.5 支持 Nightly Holly. // @note 1.4 支持 firefox 24 以下版本. // @note 1.3 修复了可能出现的文件夹列表不能自动展开和获取上次文件夹的问题. @@ -18,9 +19,11 @@ // ==/UserScript== (function() { if (location == "chrome://browser/content/browser.xul") { + var olduimod = false;//是否移动添加书签五角星到地址栏 + var hidedropmarker = false;//是否隐藏dropmarker,配合bookmarkBtn.uc.js效果更佳 var bookmarkPage = PlacesCommandHook.bookmarkPage.toString().replace(/^function.*{|}$/g, "").replace("PlacesUtils.unfiledBookmarksFolderId", "_getLastFolderId()"); 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:250px !important; max-width:300px !important';document.getElementById('editBookmarkPanel').style.maxHeight='800px'}, 0); $&")); + 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" ||')); window._getLastFolderId = function() { @@ -28,8 +31,7 @@ var annos = PlacesUtils.annotations; var folderIds = annos.getItemsWithAnnotation(LAST_USED_ANNO); var _recentFolders = []; - for (var i = 0; i -< folderIds.length; i++) { + for (var i = 0; i < folderIds.length; i++) { var lastUsed = annos.getItemAnnotation(folderIds[i], LAST_USED_ANNO); _recentFolders.push({ folderId: folderIds[i], @@ -39,7 +41,7 @@ _recentFolders.sort(function(a, b) { if (b.lastUsed < a.lastUsed) return -1; if (b.lastUsed > - a.lastUsed) return 1; + a.lastUsed) return 1; return 0; }); return _recentFolders.length > 0 ? _recentFolders[0].folderId : PlacesUtils.unfiledBookmarksFolderId; @@ -54,7 +56,7 @@ e.stopPropagation() } }.toString().replace(/^function.*{|}$/g, ""); - if (version < 24) { + if (version < 23) { eval("PlacesStarButton.onClick=function PSB_onClick(e) {" + onClick + "}"); } else { eval("BookmarkingUI.onCommand=function PSB_onClick(e) {" + onClick + "}"); @@ -83,6 +85,43 @@ var bookmarksMenuBtn = document.getElementById('bookmarks-menu-button'); var starbutton = document.getAnonymousNodes(bookmarksMenuBtn)[1]; } + + //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/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjZB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MZufm97vs3c2GoY4fac5Knxm926jR0+5Ion/EUl+36whfd7ZGBSk+eob3MlwdEE/v/XnQr5tlmOlpU4AC32ww6nQqWROUoutsfS775yfW1HEuvs5q15cVF9p2rvTawmPXY3wyEo+LO8Ynx10IL8SEpLQ+UPVE1kiUP9vacU/F0q9Omoy1mLbjsJigpdoPNbga9jse25MBfotAszfwgMBeG+YU4jA32ycmU/AHrcucJNiFD+4pc4LALIAg6EEx60Gg02QHR0zzkswzoDRqIRJYgOBeBsYkA/SDCCMyfuz4cG+vvftZl5dVejx3MVgG0Wh2QK5fGPmewz3lcq9QcYFgQjcZhMaEJf/vV49+i8wpK//WNIyfO3AspiwuROFA0jh9HXlcFpM+JJjbxk32CQ3wn4dGvv7QrY7LmHX724C+7hsdDqcVYgtwqCOazZKKJTfxkn+AInvCydcbFrMXpORKOiEoikcFbBYvA4LgQImpiEz/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;\ + padding:0!important;\ + }\ + '); + var style = document.createProcessingInstruction('xml-stylesheet', 'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(cssStr) + '"'); + document.insertBefore(style, document.documentElement); + } + + //隐藏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); + } + starbutton.addEventListener("click", function(e) { if (e.button == 0) { PlacesCommandHook.bookmarkCurrentPage(true);