[i=s] 本帖最后由 Cye3s 于 2009-8-4 05:49 编辑 [/i]
使用方法(新,扩展版本号>=1.0)
[color=Red]原作者已不再更新,最后一个版本是0.8,其它人接手后更新1.0版本[/color]
[url=http://userchromejs.mozdev.org/]http://userchromejs.mozdev.org/[/url]
使用方法很简单:
找到[url=http://wiki.sociz.com/@%E4%B8%AA%E4%BA%BA%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E5%A4%B9%E8%AF%A6%E8%A7%A3]配置文件夹[/url]下的chrome文件夹,找到userChrome.js,结尾写入一行[code]userChrome.import("*", "UChrm");[/code]之后把各独立脚本(*.uc.js,*.uc.xul)放在 "配置文件夹/chrome"下,也就是和userChrome.js放在一起
[b]脚本收集网站[/b]
[url=http://zoolcar9.lhukie.net/mozilla/userChromeJS/]http://zoolcar9.lhukie.net/mozilla/userChromeJS/[/url] (推荐)
[url=http://extensions.geckozone.org/userChrome_js_scripts]http://extensions.geckozone.org/userChrome_js_scripts[/url]
[url=http://www.xuldev.org/misc/ucjs.php]http://www.xuldev.org/misc/ucjs.php[/url](作者写了很多好脚本,可惜很多是日语说明,这是英文说明的几个脚本)
[url=http://space.geocities.jp/alice0775/index2.html]http://space.geocities.jp/alice0775/index2.html[/url](脚本非常丰富,不过还是日语说明...)
[url=http://forum.moztw.org/viewtopic.php?p=99969]http://forum.moztw.org/viewtopic.php?p=99969[/url] Moztw上的主题
[color=Red]本论坛一位好心人收集整理的独立脚本[/color],很全,我就省事了,本帖就不再经常更新了,哈
[url=http://board.mozest.com/viewthread.php?tid=26773]http://board.mozest.com/viewthread.php?tid=26773[/url]
[b]mozillazine上的主题[/b]
[url=http://forums.mozillazine.org/viewtopic.php?t=397735&postdays=0&postorder=asc&postsperpage=15&start=0]http://forums.mozillazine.org/viewtopic.ph...=15&start=0[/url]
JS中如果想增加中文菜单,请先转换成JavaScript escapes格式,再设置到label中.在线转换:
[url=http://people.w3.org/rishida/scripts/uniview/conversion.php]http://people.w3.org/rishida/scripts/uniview/conversion.php[/url]
-------------------------------下面内容可以不用看了,过时了------------------------------------------------
使用方法(旧,扩展版本号<=0.8):
1.先安装扩展(只有3K)
[url=http://forums.mozillazine.org/viewtopic.php?t=556229]http://forums.mozillazine.org/viewtopic.php?t=556229[/url]
或[url=http://mozilla.zeniko.ch/userchrome.js.xpi]http://mozilla.zeniko.ch/userchrome.js.xpi[/url]
作者主页:[url=http://mozilla.zeniko.ch/userchrome.js.html]http://mozilla.zeniko.ch/userchrome.js.html[/url]
2.编辑%配置文件夹\%chrome\userChrome.js,加入网上找到的userChrome.js代码,保存,重启Firefox,生效
或使用下面的方法,方便维护:
用下面的userChrome.js文件替换原 %配置文件夹%\chrome 下同名文件
[attach]12773[/attach]
用于加载 %配置文件夹%\chrome 目录下的所有*.uc.js与*.uc.xul
实现不同功能的代码分别保存成独立uc.js脚本,名字任意,但扩展名必需是uc.js.
要禁用某个脚本只要改扩展名或移动到子目录中,如:%配置文件夹%\chrome\Disabled
例如我机子上的结构为:[code]%Profiles%CHROME
│ TheWorld.uc.js
│ toggleFindbar.uc.js
│ stayopenmenu.uc.xul
│ userChrome.css
│ userChrome.js
└─Disable
00hideTitleBar.uc.js
CopyTitle.uc.js
hidemenubar.uc.js[/code][color=#ff0000]已知Bug[/color]:如果有使用.uc.xul,会造成.uc.js中修改界面的代码失效(如调整工具栏图标大小,隐藏菜单),功能代码正常.
[color=#ff0000]2008-03-02更新:[/color]
另外一个*.uc.js|*.uc.xul加载脚本:
[url=http://pirlouy42.free.fr/Firefox/userChrome.js/userChrome.js]http://pirlouy42.free.fr/Firefox/userChrome.js/userChrome.js[/url]
效率似乎没有上一个高
但它能很好地支持*.uc.xul脚本,不会造成*.uc.js中修改界面代码失效
并且支持以下注释(@include部分指定在哪个窗口生效,这个例子是主窗口,这只是说明文字,不是代码)[code]<!--
// ==UserScript==
// @name User Agent Switcher Lite
// @namespace https://addons.mozilla.org
// @description Remove Cookie(s) for Site
// @include chrome://browser/content/browser.xul
// @author Dwipal
// @compatibility Firefox 2.0 3.0
// @modified by Alice0775
// @version 0.3 mod 2007/08/13 10:00
// ==/UserScript==
-->[/code][[i] 本帖最后由 Cye3s 于 2008-11-19 10:02 编辑 [/i]]
2008-12-01:新的通用加强版本,[url]http://mozilla.sociz.com/viewthread.php?tid=27133&extra=page%3D1[/url]
一个例子,在右键菜单中加入LaunchIE(可替代IE View),用IE查看当前页面或链接[code]var LaunchIE = {
mSchemes: ["file", "ftp", "http", "https"],
init: function()
{
this.mItem = document.createElement("menuitem");
this.mItem.setAttribute("label", "LaunchIE");
this.mItem.setAttribute("accesskey", "u");
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", function() { LaunchIE.onPopupShowing(this); }, false);
},
onPopupShowing: function(aPopup)
{
aPopup.insertBefore(this.mItem, document.getElementById("context-sep-" + ((gContextMenu.onLink)?"open":"stop")));
this.mItem.setAttribute("oncommand", "LaunchIE.launch(" + ((gContextMenu.onLink)?"gContextMenu.linkURI":"gBrowser.currentURI") + ");");
this.mItem.hidden = !gContextMenu.onLink && (gContextMenu.isTextSelected || gContextMenu.onImage || gContextMenu.onTextInput);
this.mItem.setAttribute("disabled", this.mItem.hidden || !this.isSupported((gContextMenu.onLink)?gContextMenu.linkURI:gBrowser.currentURI));
},
launch: function(aURI, aApp)
{
if (!this.isSupported(aURI))
{
throw new Error("LaunchIE: unsupported URI scheme '" + aURI.scheme + "'!");
}
var iexplore = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
try
{
var regkey = Components.classes["@mozilla.org/windows-registry-key;1"].createInstance(Components.interfaces.nsIWindowsRegKey);
regkey.open(Components.interfaces.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\" + (aApp || "IEXPLORE.EXE"), Components.interfaces.nsIWindowsRegKey.ACCESS_READ);
iexplore.initWithPath(regkey.readStringValue(""));
regkey.close();
}
catch (ex)
{
iexplore.initWithPath((Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get("PROGRAMFILES") || "C:\\Program Files") + "\\Internet Explorer\\iexplore.exe");
}
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(iexplore);
process.run(false, [aURI.spec], 1);
},
isSupported: function(aURI)
{
return this.mSchemes.indexOf(aURI.scheme) > -1;
}
};
LaunchIE.init();[/code]
[[i] 本帖最后由 Cye3s 于 2008-12-1 10:23 编辑 [/i]]
自己改写的:调用其它浏览器,如TheWorld,并使用中文菜单(中文转换为Unicode)[code]var LaunchTW = {
mSchemes: ["file", "ftp", "http", "https"],
init: function()
{
this.mItem = document.createElement("menuitem");
this.mItem.setAttribute("label", "\u7528TheWorld\u67E5\u770B");
this.mItem.setAttribute("accesskey", "U");
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", function() { LaunchTW.onPopupShowing(this); }, false);
},
onPopupShowing: function(aPopup)
{
aPopup.insertBefore(this.mItem, document.getElementById("context-sep-" + ((gContextMenu.onLink)?"open":"stop")));
this.mItem.setAttribute("oncommand", "LaunchTW.launch(" + ((gContextMenu.onLink)?"gContextMenu.linkURI":"gBrowser.currentURI") + ");");
this.mItem.hidden = !gContextMenu.onLink && (gContextMenu.isTextSelected || gContextMenu.onImage || gContextMenu.onTextInput);
this.mItem.setAttribute("disabled", this.mItem.hidden || !this.isSupported((gContextMenu.onLink)?gContextMenu.linkURI:gBrowser.currentURI));
},
launch: function(aURI, aApp)
{
if (!this.isSupported(aURI))
{
throw new Error("LaunchTW: unsupported URI scheme '" + aURI.scheme + "'!");
}
var iexplore = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
iexplore.initWithPath("D:\\Program Files\\TheWorld\\TheWorld.exe");
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
process.init(iexplore);
process.run(false, [aURI.spec], 1);
},
isSupported: function(aURI)
{
return this.mSchemes.indexOf(aURI.scheme) > -1;
}
};
LaunchTW.init();[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-4 08:54 编辑 [/i]]
在标签菜单中增加"粘贴并转到",改自
[url=http://zoolcar9.lhukie.net/mozilla/userChromeJS/paste-to-tab-and-go.uc.js]http://zoolcar9.lhukie.net/mozilla/userChr...ab-and-go.uc.js[/url]
只换成中文菜单
如果想在后台加载,修改
var loadInBackground = nsPreferences.getBoolPref(prefString, false);
为
var loadInBackground = nsPreferences.getBoolPref(prefString, true);[code](function() {
if (typeof pg2_PasteAndGo == "function") return;
// create menuitem
var newItem = document.createElement("menuitem");
newItem.id = "paste-and-go-in-tab";
newItem.setAttribute("label", "\u7C98\u8D34\u5E76\u8F6C\u5230");
newItem.setAttribute("oncommand", "this.pasteAndGo();");
newItem.setAttribute("accesskey", "G");
newItem.pasteAndGo = function() {
var prefString = "userChromeJS.PasteAndGoInTab.loadInBackground";
var loadInBackground = nsPreferences.getBoolPref(prefString, false);
var tabbrowser = getBrowser();
var paste = readFromClipboard();
if (!paste) return;
if (tabbrowser.mContextTab.localName == 'tabs') {
tabbrowser.loadOneTab(paste, null, null, null, loadInBackground, true);
} else {
tabbrowser.mContextTab.linkedBrowser.loadURI(paste, null, null, true);
if (!loadInBackground) tabbrowser.selectedTab = tabbrowser.mContextTab;
}
}
// add menuitem to tab context menu
var tabContext = document.getAnonymousElementByAttribute(
gBrowser, "anonid", "tabContextMenu");
tabContext.insertBefore(newItem, tabContext.firstChild);
// disable menuitem if there's no text in clipboard
tabContext.addEventListener("popupshowing", function(aEvent) {[/code]改进版本:判断剪贴板中的内容是不是URL,不是则隐藏菜单(感谢drag&go脚本中的正则式)[code]/*-----------------------------------------------------
Paste to Tab and Go
Add Paste and Go menuitem to tab context menu
to paste URL from clipboard
and load it in current tab or a new tab
-----------------------------------------------------*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Paste to Tab and Go script for userChrome.js
*
* The Initial Developer of the Original Code is LouCypher.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s) (alphabetical order):
* LouCypher <loucypher.moz@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
(function() {
if (typeof pg2_PasteAndGo == "function") return;
// create menuitem
var newItem = document.createElement("menuitem");
newItem.id = "paste-and-go-in-tab";
newItem.setAttribute("label", "\u7C98\u8D34\u5E76\u8F6C\u5230");
newItem.setAttribute("oncommand", "this.pasteAndGo();");
newItem.setAttribute("accesskey", "G");
newItem.pasteAndGo = function() {
var prefString = "userChromeJS.PasteAndGoInTab.loadInBackground";
var loadInBackground = nsPreferences.getBoolPref(prefString, false);
var tabbrowser = getBrowser();
var paste = readFromClipboard();
if (!paste) return;
if (tabbrowser.mContextTab.localName == 'tabs') {
tabbrowser.loadOneTab(paste, null, null, null, loadInBackground, true);
} else {
tabbrowser.mContextTab.linkedBrowser.loadURI(paste, null, null, true);
if (!loadInBackground) tabbrowser.selectedTab = tabbrowser.mContextTab;
}
}
// add menuitem to tab context menu
var tabContext = document.getAnonymousElementByAttribute(
gBrowser, "anonid", "tabContextMenu");
tabContext.insertBefore(newItem, tabContext.firstChild);
// disable menuitem if there's no text in clipboard
tabContext.addEventListener("popupshowing", function(aEvent) {
/*var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
try {
var pasteURL = ioService.newURI(readFromClipboard(), null, null);
} catch(ex) {
}*/
var pasteURL = readFromClipboard();
var menuItem = document.getElementById("paste-and-go-in-tab");
if (pasteURL) menuItem.tooltipText = readFromClipboard();
//menuItem.setAttribute("disabled", !pasteURL ? true : false);
menuItem.setAttribute("disabled", !pasteURL ? true : (/^file:\/{3}|^data:.+|^(?!java script:)\S*?(([\w-]\.)+\w{2,7}|localhost([:\/]|$))\S*$/.test(pasteURL) ? false : true));
}, false);
var copyTabUrlTMP = document.getElementById("tm-copyTabUrl");
if (copyTabUrlTMP)
tabContext.insertBefore(copyTabUrlTMP, newItem.nextSibling);
})();[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-4 08:55 编辑 [/i]]
在未载入的图像右键菜单加入"显示图片",强制重新载入图片,从Show Image扩展修改而来,又少装一个扩展,哦耶 :rolleyes:
[color=#FF0000]3.0已自带这个功能[/color][code]var showImage = {
showImageInit:function()
{
this.mItem = document.createElement("menuitem");
this.mItem.setAttribute("label", "\u91CD\u65B0\u8F7D\u5165\u56FE\u7247");
this.mItem.setAttribute("accesskey", "L");
document.getElementById( "contentAreaContextMenu" ).addEventListener( "popupshowing", function() { showImage.onPopupShowing(this); }, false );
},
onPopupShowing: function(aPopup)
{
aPopup.insertBefore(this.mItem, document.getElementById("context-viewimage"));
this.mItem.setAttribute("oncommand", "showImage.performShowImage(true);");
this.mItem.hidden = !(gContextMenu.onImage && (!gContextMenu.target.naturalWidth || !gContextMenu.target.complete));
this.mItem.setAttribute("disabled", this.mItem.hidden);
},
performShowImage:function(reload)
{
var imgNode = gContextMenu.target;
var prefService = Components.classes[ "@mozilla.org/preferences-service;1" ]
.getService( Components.interfaces.nsIPrefBranch );
var oriImageBehavior = 0;
if( prefService.getIntPref( "permissions.default.image") != 0 )
{
oriImageBehavior = prefService.getIntPref( "permissions.default.image" );
prefService.setIntPref( "permissions.default.image", 0 );
}
var imgSrc = imgNode.getAttribute( "src" );
imgNode.setAttribute( "src","" );
if( reload == true )
{
var imgURI = imgNode.currentURI;
var imageCacheService = Components.classes[ '@mozilla.org/image/cache;1' ]
.getService( Components.interfaces.imgICache );
imageCacheService.removeEntry( imgURI );
}
imgNode.setAttribute( "src", imgSrc );
if( oriImageBehavior != 0 )
{
prefService.setIntPref( "permissions.default.image", oriImageBehavior );
}
return;
}
};
showImage.showImageInit();[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-4 08:56 编辑 [/i]]
【转换搜索引擎后马上搜索】这段代码的作用于搜索框,如果你搜索框已经有了关键字,此时想切换到另一个搜索引擎搜索的时候。只要转换引擎,转换后马上用你转换后的搜索引擎发起搜索。[code](function() {
var searchbar = document.getElementById("searchbar");
eval("searchbar.onEnginePopupCommand = "
+ searchbar.onEnginePopupCommand.toString().replace(/}$/,
"if(this.getAttribute('empty') != 'true' &&\
this.textbox.value.length)\
this.textbox.onTextEntered();\
}")
);
})();[/code]
[[i] 本帖最后由 nettrottist 于 2008-9-21 16:07 编辑 [/i]]
代替Compact Menu[code](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);
})();[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-2 16:21 编辑 [/i]]
很好很强大 <img src="http://forums.mozine.cn/style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> <br /><br /><!--coloro:#FF0000--><span style="color:#FF0000"><!--/coloro-->楼主能不能帮我修改下,拖放中右击中断,我知道能拖放到工具栏和esc取消,但是我很不喜欢 <img src="http://forums.mozine.cn/style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> <br /><br />就是这个原因我不用dragandgo,谢谢楼主<!--colorc--></span><!--/colorc--><br /><br />drag&go<br /><br /><br />contentAreaDNDObserver.onDragOver = function(aEvent, aFlavour, aDragSession) {<br /><br />// left click position<br /> if(!this.OverAlready) {<br /> this.StartDragX = aEvent.screenX;<br /> this.StartDragY = aEvent.screenY;<br /> this.OverAlready = true;<br /> }<br /><br /> aEvent.target.setAttribute("dragover", "true");<br /> return (aDragSession.canDrop = true);<br />};<br /><br />contentAreaDNDObserver.__preUC_onDrop = contentAreaDNDObserver.onDrop;<br />contentAreaDNDObserver.onDrop = function(aEvent, aXferData, aDragSession) {<br /><br /><br /> var EndDragX = aEvent.screenX; <br /> var EndDragY = aEvent.screenY;<br /> <br /> var direction;<br /> var xStart = contentAreaDNDObserver.StartDragX;<br /> var yStart = contentAreaDNDObserver.StartDragY;<br /> var DistanceX = Math.abs(EndDragX - xStart);<br /> var DistanceY = Math.abs(EndDragY - yStart);<br /> var Geste = false ;<br />// Chose a tolerance for gesture <br /> var Tolerance = 10;<br /> <br /> if( DistanceX > Tolerance || DistanceY > Tolerance)<br /> {<br /> Geste = true;<br /> if (DistanceX > DistanceY)<br /> direction = xStart < EndDragX ? "R" : "L";<br /> else direction = yStart < EndDragY ? "D" : "U"; <br /> }<br /><br /> var xferData = aXferData.data.split("\n");<br />// window.confirm(xferData);<br /> <br /> if (Geste == true)<br /> {<br /> var url = (/^\s*(.*?)\s*$/m.test(aXferData.data))?RegExp.$1:null;<br /> if (!url)<br /> {<br /> this.__preUC_onDrop(aEvent, aXferData, aDragSession);<br /> return;<br /> }<br />// if (/^file:\/{3}(?:.*\/)?(.+\.xpi)$/.test(url)) // local XPI -> install<br /> if (/.*\.xpi$/.test(url)) // local XPI -> install<br /> {<br /> var xpinstallObj = {};<br /> xpinstallObj[RegExp.$1] = url;<br /> <br /> for (var i = 1; i < aDragSession.numDropItems; i++)<br /> { // allow to install several extensions at once<br /> url = this.__UC_getDroppedURL(aDragSession, i);<br /> if (/.*\.xpi$/.test(url))<br /> xpinstallObj[RegExp.$1] = url; <br /> } <br /> InstallTrigger.install(xpinstallObj);<br /> }<br /> // if it's an image<br /> else if(/^\[Image\] /.test(xferData[1]) && !(/^(file\:\/\/\/)/.test(url)) )<br /> {<br />// window.confirm("image");<br /> if(!aEvent.ctrlKey) <br /> saveURL(url, null, null, false, true);<br /> } <br /> // if it's a link<br /> else if (/^file:\/{3}|^data:.+|^(?!java script:)\S*?(([\w-]\.)+\w{2,7}|localhost([:\/]|$))\S*$/.test(url))<br /> {<br />// window.confirm("link");<br /> gBrowser.dragDropSecurityCheck(aEvent, aDragSession, url); <br /> var referrer = gBrowser.currentURI;<br /> if (referrer.spec == "about:blank")<br /> loadURI(url, null, null);<br /> else this.__UC_loadInTab(url, aEvent);<br /> <br /> for (i = 1; i < aDragSession.numDropItems; i++)<br /> {<br /> url = this.__UC_getDroppedURL(aDragSession, i);<br /> gBrowser.dragDropSecurityCheck(aEvent, aDragSession, url);<br /> gBrowser.addTab(url, referrer);<br /> }<br /> }<br /> else // text string -> web search<br /> { <br />// window.confirm("text");<br /> // here you can choose URL for each gesture<br /> if (direction=="R" && (aDragSession.sourceDocument) )<br /> openURL = "http://www.google.fr/search?q=";<br /> if (direction=="L" && (aDragSession.sourceDocument) )<br /> openURL = "http://fr.wikipedia.org/wiki/Special:Search?search=";<br /> if (direction=="D" && (aDragSession.sourceDocument) )<br /> openURL = "http://www.wordreference.com/fren/";<br /> if (direction=="U" && (aDragSession.sourceDocument) )<br /> openURL = "http://www.wordreference.com/enfr/";<br /><br /> this.__UC_loadInTab(openURL + encodeURIComponent(url), aEvent);<br /> }<br /> }<br /> aEvent.preventDefault();<br /> contentAreaDNDObserver.OverAlready = false;<br />};<br /><br />contentAreaDNDObserver.__preUC_onDragStart = contentAreaDNDObserver.onDragStart;<br />contentAreaDNDObserver.onDragStart = function(aEvent, aXferData, aDragAction) {<br /><br /> // prevent images of being dragged themselves (drag a link to them instead)<br /> <br /> // make sure we're dragging an image<br /> var target = aEvent.originalTarget;<br /> if (!/^img$/i.test(target.localName)) throw new Error(); // fall back to default drag handler<br /><br /> // make sure we've actually got a link to drag<br /> for (var obj = target.parentNode; obj && !/^a$/i.test(obj.localName); obj = obj.parentNode);<br /> var url = ((obj)?obj.href:null) || target.src;<br /> if (!url) throw new Error();<br /><br /> var caption = ((obj)?obj.title:null) || target.title || target.alt || url.replace(/^.*\//, "") || url; <br /> aXferData.data = new TransferData();<br />// aXferData.data.addDataForFlavour("text/x-moz-url", url + "\n" + caption);<br /> // mark unlinked images as downloadable by onDrop ("[Image] ")<br /> aXferData.data.addDataForFlavour("text/x-moz-url", url + "\n" + ((obj)?"":"[Image] ") + caption);<br /> aXferData.data.addDataForFlavour("text/unicode", url);<br /> aXferData.data.addDataForFlavour("text/html", '<a href="' + url + '">' + caption + '</a>');<br /> <br /> var nsIDragService = Components.interfaces.nsIDragService;<br /> aDragAction.action = nsIDragService.DRAGDROP_ACTION_COPY | nsIDragService.DRAGDROP_ACTION_MOVE | nsIDragService.DRAGDROP_ACTION_LINK;<br /> <br /> <br />};<br /><br /><br />contentAreaDNDObserver.__UC_loadInTab = function(aURL, aEvent) {<br /> var newTab = gBrowser.addTab(aURL, gBrowser.currentURI);<br />// if (gPrefService.getBoolPref("browser.tabs.loadInBackground") != !(aEvent && aEvent.shiftKey))<br />// {<br /> gBrowser.selectedTab = newTab;<br />// }<br />};<br /><br />contentAreaDNDObserver.__UC_getDroppedURL = function(aDragSession, aIndex) {<br /> try<br /> {<br /> var xfer = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);<br /> xfer.addDataFlavor("application/x-moz-file", "nsIFile");<br /> xfer.addDataFlavor("text/x-moz-url");<br /> xfer.addDataFlavor("text/unicode");<br /> aDragSession.getData(xfer, aIndex);<br /> <br /> var flavour = {}, data = {}, length = {};<br /> xfer.getAnyTransferData(flavour, data, length);<br /> var xferData = new FlavourData(data.value, length.value, this.getSupportedFlavours().flavourTable[flavour.value]);<br /> <br /> return transferUtils.retrieveURLFromData(xferData.data, xferData.flavour.contentType);<br /> }<br /> catch (ex)<br /> {<br /> return null;<br /> }<br />};<br /><br />getBrowser().addEventListener("dragover", function(aEvent) { nsDragAndDrop.dragOver(aEvent, contentAreaDNDObserver); }, false);<br />gBrowser.addEventListener("drop", function(aEvent) { nsDragAndDrop.dragOver(aEvent, contentAreaDNDObserver); }, false);<br />gBrowser.addEventListener("draggesture", function(aEvent) { nsDragAndDrop.startDrag(aEvent, contentAreaDNDObserver); }, true);
试了下,拖动事件触发函数后,函数内不能接受新的右键点击事件...不知道怎么改...等高手:-(
<!--quoteo(post=110253:date=2007年12月28日 12:06 PM:name=Cye3s)--><div class='quotetop'>引用 (Cye3s @ 2007年12月28日 12:06 PM) <a href="index.php?act=findpost&pid=110253"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->试了下,拖动事件触发函数后,函数内不能接受新的右键点击事件...不知道怎么改...等高手:-(<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br /><br />可否模拟esc按键,我看了javascript教程,只有使用wsh的 <img src="http://forums.mozine.cn/style_emoticons/<#EMO_DIR#>/sweatingbullets.gif" style="vertical-align:middle" emoid=":sweatingbullets:" border="0" alt="sweatingbullets.gif" />
ESC也一样,我不知道怎么在函数里监听新事件:-(正在学习别人的代码<br /><br />代替鼠标手势All-in-One Gestures的脚本:<br /><a href="http://www.xuldev.org/blog/?p=73" target="_blank">http://www.xuldev.org/blog/?p=73</a>
配合DownThemAll!(1.0b3上测试通过)
比如我的下载目录默认为E:\Downloads\ ,本次下载临时改变保存路径为E:\temp,下次下载要手工改回E:\Downloads\ ,命名规则也类似,我经常是忘了改 :sweatingbullets: ,结果下载的东西全乱了.这个脚本在每次调用下载前重置下载目录和命名规则. :rolleyes:[code]var dtaDefault = {
reset:function(){
var ps = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
ps.setCharPref("extensions.dta.directory",'["E:\\\\Downloads\\\\", "E:\\\\Downloads\\\\tmpath\\\\", "E:\\\\"]');
ps.setCharPref("extensions.dta.renaming",'["*name*.*ext*", "*text*", "*num*_*name*.*ext*", "*url*-*name*.*ext*", "*name* (*text*).*ext*", "*name* (*hh*-*mm*).*ext*"]');
ps.setBoolPref("extensions.dta.lastqueued",false);
},
setMenu:function(menuID){
document.getElementById(menuID).setAttribute("oncommand", "dtaDefault.reset();"+document.getElementById(menuID).getAttribute("oncommand"));
},
init:function() {
dtaDefault.setMenu("dta-manager-button");
dtaDefault.setMenu("dtaToolsManager");
dtaDefault.setMenu("dtaCtxDTA");
dtaDefault.setMenu("dtaCtxTDTA");
dtaDefault.setMenu("dtaCtxSave");
dtaDefault.setMenu("dtaCtxSaveT");
dtaDefault.setMenu("dtaToolsDTA");
dtaDefault.setMenu("dtaToolsTDTA");
dtaDefault.setMenu("dtaCtxSave-direct");
dtaDefault.setMenu("dtaCtxSaveT-direct");
dtaDefault.setMenu("dtaCtxDTA-direct");
dtaDefault.setMenu("dtaCtxTDTA-direct");
}
}
dtaDefault.reset();
window.setTimeout(function() {
dtaDefault.init();
});[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-4 08:57 编辑 [/i]]
代替TabMixPlus部分功能,地址栏和书签在新标签(在当前标签右边)中打开
新标签打开(目前只在Firefox 3 Beta3上测试通过,历史栏还不能在新标签中打开):[code]eval("BrowserLoadURL = " + BrowserLoadURL.toString().replace("e;", "[ DISCUZ_CODE_0 ] if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (!aTriggeringEvent.altKey)) { var tab = gBrowser.addTab(); gBrowser.selectedTab = tab; }"));
eval("PlacesController.prototype.openSelectedNodeIn = " + PlacesController.prototype.openSelectedNodeIn.toString().replace('openUILinkIn(node.uri, aWhere);','var tabBrowser = null, browserWindow = getTopWin(); if (browserWindow) tabBrowser = browserWindow.getBrowser(); if (tabBrowser && (tabBrowser.currentURI.spec != "about:blank" || tabBrowser.webProgress.isLoadingDocument) && (!/^j/.test(node.uri) && aWhere == "current")) aWhere = "tab"; [ DISCUZ_CODE_0 ]'));
[/code]在当前标签右边打开:[code]/* Open tab right to the current one */
eval("gBrowser.addTab ="+gBrowser.addTab.toString().replace(
'if (!blank)',
'this.moveTabTo(t,this.mCurrentTab._tPos+1);'+
'if (!blank)'));
eval("gBrowser.moveTabTo = " + gBrowser.moveTabTo.toString().replace("this.mTabContainer.childNodes[i].selected = false;"));[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-4 08:58 编辑 [/i]]
有right encoding, autocopy, open text link的代码么?
<!--quoteo(post=114168:date=2008年2月17日 10:36 AM:name=我行我速)--><div class='quotetop'>引用 (我行我速 @ 2008年2月17日 10:36 AM) <a href="index.php?act=findpost&pid=114168"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->有right encoding, autocopy, open text link的代码么?<!--QuoteEnd--></div><!--QuoteEEnd--><br />2008-02-28修改:<br />right encoding原来的xul实现方法太笨,去掉了,见39楼有新代码 <img src="http://forums.mozine.cn/style_emoticons/<#EMO_DIR#>/thumbsup.gif" style="vertical-align:middle" emoid=":thumbsup:" border="0" alt="thumbsup.gif" />
搜索栏相关:
以下均在Firefox 3 Beta3下测试通过,其它版本可能要修改查找栏命令名称.
搜索栏置顶:[code]/* Find bar on top */
if (location != "chrome://browser/content/browser.xul") throw "stop";
(function () {
var findbar = document.getElementById('FindToolbar');
//move findbar to the top
var tabpanels = gBrowser.mPanelContainer;
tabpanels.parentNode.insertBefore(findbar, tabpanels);
//bottom border
findbar.setAttribute("style", "-moz-border-bottom-colors: none;");
})();[/code]CTRL+F切换搜索栏状态,按一次打开,再按一次关闭:[code]// Toolbar button and Ctrl-F handler.
function toggleFindbar() {
if((document.getElementById('FindToolbar')).hidden == true) {
gFindBar.onFindCommand();
}
else gFindBar.close();
}
document.getElementById("cmd_find").setAttribute("oncommand", "toggleFindbar();");[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-2 16:26 编辑 [/i]]
<!--quoteo(post=114192:date=2008年2月17日 1:35 PM:name=Cye3s)--><div class='quotetop'>引用 (Cye3s @ 2008年2月17日 1:35 PM) <a href="index.php?act=findpost&pid=114192"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec--><!--quoteo(post=114168:date=2008年2月17日 10:36 AM:name=我行我速)--><div class='quotetop'>引用 (我行我速 @ 2008年2月17日 10:36 AM) <a href="index.php?act=findpost&pid=114168"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->有right encoding, autocopy, open text link的代码么?<!--QuoteEnd--></div><!--QuoteEEnd--><br />right encoding,记得保存成*.uc.xul,去掉一些代码,不然会有两个菜单,去掉的代码好像是用于Frame的,不太清楚,你先试试 <img src="http://forums.mozine.cn/style_emoticons/<#EMO_DIR#>/sweatingbullets.gif" style="vertical-align:middle" emoid=":sweatingbullets:" border="0" alt="sweatingbullets.gif" /> <br />另两个要转应该也可以,不过改动可能很大,不如直接装扩展<!--QuoteEnd--></div><!--QuoteEEnd--><br />我可不想把AutoCopy整个扩展搞来,我想要的功能其实很简单,就是选中即复制,并且直接粘贴在搜索栏(search bar)。<br />另外,open text link可以通过搜索引擎直接实现么?
[quote]原贴: (我行我速 @ 2008年2月17日 4:17 PM) [url=http://hall.sociz.com/index.php?act=findpost&pid=114206][img]http://board.sociz.com/images/common/back.gif[/img][/url]
[quote]原贴: (Cye3s @ 2008年2月17日 1:35 PM) [url=http://hall.sociz.com/index.php?act=findpost&pid=114192][img]http://board.sociz.com/images/common/back.gif[/img][/url]
[quote]原贴: (我行我速 @ 2008年2月17日 10:36 AM) [url=http://hall.sociz.com/index.php?act=findpost&pid=114168][img]http://board.sociz.com/images/common/back.gif[/img][/url]
有right encoding, autocopy, open text link的代码么?[/quote]
right encoding,记得保存成*.uc.xul,去掉一些代码,不然会有两个菜单,去掉的代码好像是用于Frame的,不太清楚,你先试试 :sweatingbullets:
另两个要转应该也可以,不过改动可能很大,不如直接装扩展[/quote]
我可不想把AutoCopy整个扩展搞来,我想要的功能其实很简单,就是选中即复制,并且直接粘贴在搜索栏(search bar)。
另外,open text link可以通过搜索引擎直接实现么?
[/quote]
这个有点难度,毕竟我对JS和XUL不熟悉...而且还是看别人写的没注释的代码 :sweatingbullets:
本来about:config里有个clipboard.autocopy参数,好像是选中即复制功能,不过只能工作在Linux下,直接拖动文件到搜索栏也行
open text link?文本形的URL?有装超级拖拽扩展的话不是选中后用拖放就行了么?JS写的话要扫描所有内容,替换成HTML格式的链接,效率可能不好. :sweatingbullets:
试试这个脚本,在搜索引擎上点击中键自动搜索剪贴板内容,至少能省点事[code]/**
* A user script for userChrome.js extension.
* @name Search Clipboard
* @description Search clipboard by middle-clicking the current engine button or engine popup.
* @compatibility Firefox 2.0
* @author Gomita
* @version 1.0.20061026
* @permalink http://www.xuldev.org/blog/?p=53
*/
(function()
{
var searchClipboard = function(event)
{
if ( event.button != 1 ) return;
// get clipboard text
try {
var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard);
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("text/unicode");
clip.getData(trans, clip.kGlobalClipboard);
var str = new Object();
var len = new Object();
trans.getTransferData("text/unicode", str, len);
if ( str )
str = str.value.QueryInterface(Components.interfaces.nsISupportsString).toString();
else
return;
} catch(ex) {
return;
}
// get nsISearchEngine object
var engine = event.target.engine;
if ( !engine ) engine = document.getElementById("searchbar").currentEngine;
// get nsISearchSubmission object
var submission = engine.getSubmission(str, null);
if ( !submission ) return;
// decide whether using a new tab or not
var inNewTab = gPrefService.getBoolPref("browser.search.openintab");
inNewTab = ((event && event.altKey) ^ inNewTab);
// load the URL
if ( inNewTab ) {
var tab = getBrowser().loadOneTab(submission.uri.spec, null, null, submission.postData, null, false);
gBrowser.selectedTab = tab;
} else {
loadURI(submission.uri.spec, null, submission.postData, false);
}
// hide popup after middle-clicking the search popup
if ( event.target.localName == "menuitem" ) {
event.target.parentNode.hidePopup();
event.preventBubble();
}
};
var searchbar = document.getElementById("searchbar");
// search clipboard by middle-click the search engine popup
document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-popup")
.addEventListener("click", searchClipboard, false);
// search clipboard by middle-click the current engine button
document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-engine-button")
.addEventListener("click", searchClipboard, false);
}());[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-4 09:06 编辑 [/i]]
有没有锁定标签页(lock the tab)和保护标签页(protect the tab)的代码啊?很需要。
<!--quoteo(post=114375:date=2008年2月19日 9:03 AM:name=nettrottist)--><div class='quotetop'>引用 (nettrottist @ 2008年2月19日 9:03 AM) <a href="index.php?act=findpost&pid=114375"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->有没有锁定标签页(lock the tab)和保护标签页(protect the tab)的代码啊?很需要。<!--QuoteEnd--></div><!--QuoteEEnd--><br /><a href="http://space.geocities.yahoo.co.jp/gl/alice0775/view/20080130/1201683081" target="_blank">http://space.geocities.yahoo.co.jp/gl/alic...0130/1201683081</a> 很精简,不太会用。<br /><br /><a href="http://space.geocities.yahoo.co.jp/gl/alice0775/view/20071014/1192337038" target="_blank">http://space.geocities.yahoo.co.jp/gl/alic...1014/1192337038</a> 代码长些,好用。
“保护标签页”[code]
// ==UserScript==
// @name tabProtect.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description tabProtect
// @include main
// @compatibility Firefox 2.0 3.0
// @author Alice0775
tabProtect = {
debug: function(aMsg){
Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService)
.logStringMessage(aMsg.toString());
},
init: function(){
//tabbrowser.xml銈掔疆銇嶆彌銇�
//this.debug(gBrowser.removeTab.toString());
gBrowser.removeTab_old = gBrowser.removeTab;
gBrowser.removeTab =function(aTab){
this._browsers = null; // invalidate cache
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
if (aTab.hasAttribute("tabProtect")) return;
gBrowser.removeTab_old(aTab);
}
//this.debug(gBrowser.removeTab.toString());
this.tabContextMenu();
// CSS銈掗仼鐢�
if(this.getVer()<3){
var style = <![CDATA[
.tab-close-button[hidden='true'] {
display: none !important;
}
.tab-icon-protect{
list-style-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAQUlEQVQ4jWNgGAXDADASUvDvOsN/fPJMlLqAhRhFTJqo/H/XKXQBsoFEuQDDVnIMQPcGXJxYA3C5hiwvUOwCZAAAlRcK7m+YgB4AAAAASUVORK5CYII=');
}
.tab-icon-protect[hidden='true'] {
display: none !important;
}
]]>.toString();
}else{
var style = <![CDATA[
.tab-close-button[hidden='true'] {
display: none !important;
}
.tabbrowser-tab.tabProtect {
-moz-appearance: none;
height: 22px;
margin: 0px 0px 3px;
padding: 0px 1px 1px;
background-color:#00ff88;
}
.tabbrowser-tab.tabProtect[selected="true"] {
height: 23px;
margin: 0px 0px 3px;
padding: 1px 1px 0px;
background-color:#00ff88;
}
.tabbrowser-tab.tabProtect[selected="true"]:hover {
height: 23px;
margin: 0px 0px 3px;
padding: 1px 1px 0px;
background-color:#00ff88;
}
.tabbrowser-tab.tabProtect:not([selected="true"]) {
height: 19px;
margin: 0px 0px 5px;
padding: 1px 0px 1px;
background-color:#00ff88;
}
.tabbrowser-tab.tabProtect:not([selected="true"]):hover {
height: 21px;
margin: 0px 0px 5px;
padding: 1px 1px 0px;
background-color:#00ff88;
} ]]>.toString();
}
var sspi = document.createProcessingInstruction(
'xml-stylesheet',
'type="text/css" href="data:text/css,' + encodeURI(style) + '"'
);
document.insertBefore(sspi, document.documentElement);
sspi.getAttribute = function(name) {
return document.documentElement.getAttribute(name);
};
//璧峰嫊鏅傘伄銈裤儢鐘舵厠寰╁厓
var that = this;
init(0);
function init(i){
if(i < gBrowser.mTabContainer.childNodes.length){
var aTab = gBrowser.mTabContainer.childNodes[i];
if(aTab.linkedBrowser.docShell.busyFlags
|| aTab.linkedBrowser.docShell.restoringDocument){
setTimeout(init,1000,i);
}else{
that.restoreForTab(aTab);
i++;
setTimeout(init,0,i);
}
}else{
}
}
gBrowser.tabContainer.addEventListener('TabMove', tabProtect.TabMove, false);
gBrowser.tabContainer.addEventListener('SSTabRestored', tabProtect.restore,false);
window.addEventListener('unload',function(){ tabProtect.uninit();},false)
},
uninit: function(){
gBrowser.tabContainer.removeEventListener('TabMove', tabProtect.TabMove, false);
gBrowser.tabContainer.removeEventListener('SSTabRestored', tabProtect.restore,false);
// document.documentElement.removeEventListener('SubBrowserFocusMoved', function(){ tabProtect.init(); }, false);
},
getVer: function(){
const Cc = Components.classes;
const Ci = Components.interfaces;
var info = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
var ver = parseInt(info.version.substr(0,3),10);
return ver;
},
//TAB D&D
TabMove: function(aEvent){
var aTab = aEvent.target;
gBrowser.protectTabIcon(aTab);
},
tabContextMenu: function(){
//tab context menu
var tabContext = document.getAnonymousElementByAttribute(
gBrowser, "anonid", "tabContextMenu");
var menuitem = tabContext.appendChild(
document.createElement("menuitem"));
menuitem.id = "tabProtect";
menuitem.setAttribute("type", "checkbox");
menuitem.setAttribute("label", "\u4FDD\u62A4\u6807\u7B7E\u9875");
menuitem.setAttribute("accesskey", "P");
menuitem.setAttribute("oncommand","tabProtect.toggle(event);");
tabContext.addEventListener('popupshowing',function(event){tabProtect.setCheckbox(event);},false);
},
restore: function(event){
var aTab = event.originalTarget;
tabProtect.restoreForTab(aTab);
},
restoreForTab: function(aTab){
var ss = Components.classes["@mozilla.org/browser/sessionstore;1"].
getService(Components.interfaces.nsISessionStore);
var retrievedData = ss.getTabValue(aTab, "tabProtect");
if(retrievedData){
aTab.setAttribute('tabProtect',true);
var closeButton = document.getAnonymousElementByAttribute(
aTab, "anonid", "close-button");
closeButton.setAttribute('hidden',true);
}
gBrowser.protectTabIcon(aTab);
},
toggle: function(event){
var aTab = document.popupNode;
while( aTab && aTab instanceof XULElement && aTab.localName !='tab'){
aTab = aTab.parentNode;
}
if( !aTab || aTab.localName !='tab') return;
gBrowser.protectTab(aTab);
},
setCheckbox: function(event){
var menuitem = document.getElementById('tabProtect');
var aTab = document.popupNode;
while( aTab && aTab instanceof XULElement && aTab.localName !='tab'){
aTab = aTab.parentNode;
}
if( !aTab || aTab.localName !='tab'){
menuitem.setAttribute('hidden',true);
return;
}
menuitem.setAttribute('hidden',false);
if(aTab.hasAttribute('tabProtect') && aTab.getAttribute('tabProtect')){
menuitem.setAttribute('checked', true);
}else{
menuitem.setAttribute('checked', false);
}
}
}
gBrowser.protectTab = function (aTab){
var ss = Components.classes["@mozilla.org/browser/sessionstore;1"].
getService(Components.interfaces.nsISessionStore);
if ( aTab.hasAttribute("tabProtect") ){
aTab.removeAttribute("tabProtect");
ss.deleteTabValue(aTab, "tabProtect");
}else{
aTab.setAttribute("tabProtect", "true");
ss.setTabValue(aTab, "tabProtect", true);
}
this.protectTabIcon(aTab);
}
gBrowser.protectTabIcon = function (aTab){
const kXULNS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var closeButton = document.getAnonymousElementByAttribute(
aTab, "anonid", "close-button");
var image = document.getAnonymousElementByAttribute(
aTab, "class", "tab-icon-protect");
if ( aTab.hasAttribute("tabProtect") ){
closeButton.setAttribute('hidden',true);
if(!image){
var stack = document.getAnonymousElementByAttribute(
aTab, "class", "tab-icon");
var image = document.createElementNS(kXULNS,'image');
image.setAttribute('class','tab-icon-protect');
if(stack) stack.appendChild(image);
}
aTab.setAttribute('class',aTab.getAttribute('class')+' tabProtect');
image.removeAttribute('hidden');
}else{
closeButton.setAttribute('hidden',false);
if(image){
image.setAttribute('hidden', true);
}
aTab.setAttribute('class',aTab.getAttribute('class').replace(/\stabProtect/g,''));
}
}
//document.documentElement.addEventListener('SubBrowserFocusMoved', function(){ tabProtect.init(); }, false);
tabProtect.init();
[/code]
[[i] 本帖最后由 nettrottist 于 2008-11-18 08:35 编辑 [/i]]
呵呵,还要靠大家一起收集修改<br /><a href="http://space.geocities.yahoo.co.jp/gl/alice0775" target="_blank">http://space.geocities.yahoo.co.jp/gl/alice0775</a><br />有不少好脚本,可惜很多说明是日文的<br />我有空看下lock this tab能不能用 <img src="http://forums.mozine.cn/style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />
终于找到解决方案了,不容易!nettrottist 不用到处求高人改扩展了,觉得很难!多找一下 userchrome.js 的脚本吧,估计她存在就是为了满足你这类人的,很强大!<br /><br />另外,protect the tab 在FF3.0上也很好 !lock this tab 是不能用,说明上虽然是支持2.0 3.0的!
这个protect this tab的oncommand值是什么啊?我还想给他编制一个快捷键呢。
[[i] 本帖最后由 nettrottist 于 2008-9-21 17:17 编辑 [/i]]
protect this tab 151行<br />menuitem.setAttribute("label", "Protect This Tab");<br />改成<br />menuitem.setAttribute("label", "\u4FDD\u62A4\u6807\u7B7E\u9875");<br />就成中文菜单了<br /><br />代码里可以看出oncommand是tabProtect.toggle(event);<br />keyconfig里配置试试<br /><br />Lock Tab在我这里只有有视觉效果,就是标签外面加了层红框,不过不知道做什么用,本来应该是锁定的意思,不能转到其它地址.<br />我这里用TMP的锁定功能也没用
[code]/**
* A user script for userChrome.js extension.
* @name Copy Title + URL
* @description Add 'Copy Title + URL' and 'Copy Title + URL (HTML)' commands
* to the context menu of browser tab.
* @compatibility Firefox 2.0
* @author Gomita
* @lastUupdated 2007.01.12
* @permalink http://www.xuldev.org/blog/?p=51
*/
(function()
{
window.ucjs_copyTabInfo = function(aAsHTML)
{
function htmlEscape(s) {
s = s.replace(/&/g, "&");
s = s.replace(/>/g, ">");
s = s.replace(/</g, "<");
s = s.replace(/"/g, """);
return s;
}
var tab = document.popupNode;
var url = gBrowser.getBrowserForTab(tab).contentWindow.location.href;
var txt = aAsHTML ?
'<a href="' + htmlEscape(url) + '">' + htmlEscape(tab.label) + '</a>' :
tab.label + "\n" + url;
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
clipboard.copyString(txt);
};
var menuitem1 = document.createElement("menuitem");
menuitem1.setAttribute("label", "Copy Title + URL");
menuitem1.setAttribute("oncommand", "ucjs_copyTabInfo(false);");
var menuitem2 = document.createElement("menuitem");
menuitem2.setAttribute("label", "Copy Title + URL (HTML)");
menuitem2.setAttribute("oncommand", "ucjs_copyTabInfo(true);");
setTimeout(function()
{
gBrowser.mStrip.childNodes[1].appendChild(document.createElement("menuseparator"));
gBrowser.mStrip.childNodes[1].appendChild(menuitem1);
gBrowser.mStrip.childNodes[1].appendChild(menuitem2);
}, 0);
})();[/code]产生效果如下图示
[img]http://www.xuldev.org/misc/wp/CopyTitleAndURL.png[/img]
能否把菜单改成中文化的【复制标签页标题 + URL】和【复制标签页标题 + URL(HTML)】呢?不清楚这几个汉字的编码是什么。<br />还有,对于中文论坛而言,好像用URL的BBcode的情况比HTML的要多吧?
[[i] 本帖最后由 nettrottist 于 2008-9-21 16:12 编辑 [/i]]
LS的两中文编码:<br />\uFEFF\u590D\u5236\u6807\u7B7E\u9875\u6807\u9898 + URL<br />\u590D\u5236\u6807\u7B7E\u9875\u6807\u9898 + URL(HTML)<br /><br />转换方法,UltraEdit32中新建一个文件,输入要转换的文字<br />在文件→转换中选择 ASCII到Unicode ,再选择 Unicode到ASCII Escaped Unicode ,保存,用记事本打开就是了
谢谢楼上的帮忙。能不能把复制当前标签页标题 + url (html)改改啊?html格式不多见。<br /><br />我用的是emeditor这个文字编辑器, 我怎么没看到这个软件有文字编码转换?
Em的菜单和UE不一样,你得自己找找了 :sweatingbullets:
换成BBCode:[code](function()
{
window.ucjs_copyTabInfo = function(aAsBBCode)
{
var tab = document.popupNode;
var surl = gBrowser.getBrowserForTab(tab).contentWindow.location.href;
var txt = aAsBBCode ?
'[url="' + surl + '"]' + tab.label + '[/url]' :
tab.label + "\n" + surl;
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
clipboard.copyString(txt);
};
var menuitem1 = document.createElement("menuitem");
menuitem1.setAttribute("label", "\uFEFF\u590D\u5236\u6807\u7B7E\u9875\u6807\u9898 + URL");
menuitem1.setAttribute("oncommand", "ucjs_copyTabInfo(false);");
var menuitem2 = document.createElement("menuitem");
menuitem2.setAttribute("label", "\u590D\u5236\u6807\u7B7E\u9875\u6807\u9898 + URL(BBCode)");
menuitem2.setAttribute("oncommand", "ucjs_copyTabInfo(true);");
setTimeout(function()
{
gBrowser.mStrip.childNodes[1].appendChild(document.createElement("menuseparator"));
gBrowser.mStrip.childNodes[1].appendChild(menuitem1);
gBrowser.mStrip.childNodes[1].appendChild(menuitem2);
}, 0);
})();[/code]
[[i] 本帖最后由 Cye3s 于 2008-9-4 09:07 编辑 [/i]]
userChrome.js的脚本一般也可以放到custombutton按钮的初始化部分运行,很方便哦,不用重启看效果。