LETZTES UPDATE: -.2009
---
Im folgenden meine überarbeitete userchrome.js für Fx3
Achtung bei den folgenden Scripten, die ganz unten unter Punkt 50 stehen:
-
Element Inspector by LouCypher (aka Zoolcar9)
-
Findbar on top
Die können nur am Schluss stehen, weil sie mittendrin den folgenden Code blockieren. Demnach kann auch nur eines von beiden aktiv sein.
PS:
Ich musste die Codes für die Scripte der Punkte 22 und 50 raussschmeissen, da sie nicht mehr in diesen Beitrag passen. ;)
Bei Fragen zu nicht angegebenen Scripten (zB wegen des Loaders), eine PN an mich oder auch ne kleine Nachfrage im userchrome.js-Thread.
---
[code]/*
*
*********************************************************************************
*********************************************************************************
*********************************************************************************
********************************** I N H A L T **********************************
*********************************************************************************
*********************************************************************************
*********************************************************************************
*
*
* 01. Mausgesten.uc.js
* 02. Uhr in Titelleiste & Profil
* 03. Webbilder direkt übers Kontextmenü im Fx bei Imageshack hochladen
* 04. Super DragAndGo
* 05. URL to new tab
* 06. Drag'n'Duplicate
* 07. Paste and Go
*** 07.01. in Tab
*** 07.01. in url-bar
* 08. Progress in Titlebar DEAKTIVIERT
* 09. Compact Menu
* 10. Status bar in menubar
* 11. TABS
*** 11.01. Dropping Tabs Half Step Ahead
*** 11.02. Mouse Wheel on Tab Bar
*** 11.03. Tabs to the Right (cf. Tabs Open Relative)
*** 11.04. Real-time Tab Preview DEAKTIVIERT
*** 11.05. UndoListInTabmenuToo.uc.js
*** 11.06. zzzz-MultiRowTabforFx2.0_3.0_mod1.uc.js
*** 11.07. tablock.uc.js
*** 11.08. tabprotect.uc.js
*** 11.09. URL to new tab
* 12. SEARCHING
*** 12.01. Clear Search Term
*** 12.02. Scroll Search Engines in contextmenu
*** 12.03. Search Clipboard
*** 12.04. contextFindWords
*** 12.05.urlbar-splitter
*** 12.06. addResizerForSearchBar DEAKTIVIERT
*** 12.07. Middle Click & Go on urlbar-icon and searchbar-engine-icon
* 13. Copy Tab Info
* 14. Downloadmanager und Chronik im Tab öffnen
* 15. userChrome.xul DEAKTIVIERT
* 16. Sub-Script/XUL Loader
* 17. Copy Feed URL menuitem
* 18. fixbug253912ShowstheBookmarkstooltips
* 19. Save Favicon DEAKTIVIERT
* 20. Textarea Sizers
* 21. Remove accesskey attributes from ALL menus
* 22. Private Tool Menus
*
*
*
*
*
* 50. VON DIESEN GEHT NUR DAS ERSTE SCRIPT (50.01.)
*** 50.01. Find bar on top
*** 50.02. Element Inspector
*
*
*
*
*
*********************************************************************************
*********************************************************************************
*********************************************************************************
*
*
*********************************************************************************
***** 01. Mausgesten ************************************************************
*********************************************************************************
*/
// => LOADER
/*
*********************************************************************************
***** 02. Uhr in Titelleiste & Profil *******************************************
*********************************************************************************
*/
/* :::::::: Anzeige Dokument / WoTag/ Dat / Uhrzeit ::::::::::::::: */
function doDatUhr() {
var days = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
var months = ["Jan", "Feb", "März", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"];
window.setTimeout("try{doDatUhr()}catch(ex){}", 1000 );
var title = content.document.title;
var D = new Date();
var day = days[D.getDay()];
var month = months[D.getMonth()];
var year = D.getFullYear();
var hour = D.getHours();
var minute = D.getMinutes();
var second = D.getSeconds();
var date = day + ", " + (D.getDate() < 10 ? "0" +D.getDate() : D.getDate()) + ". " + month + ". " + year;
var time = (hour < 10 ? "0" +hour : hour) + ":" + (minute < 10 ? "0" +minute : minute) + ":" + (second < 10 ? "0" +second : second);
// var timestr = " >>>>> " + date + ", " + time+ " Uhr <<<< ";
var timestr = date + ", " + time+ " |||||>>> ";
var profil = "Profil: User 3.0.3 || "
document.title = profil + timestr + title;
document.documentElement.setAttribute("titlepreface", profil + timestr);
}
doDatUhr();
document.documentElement.setAttribute("titlemodifier", "");
document.documentElement.setAttribute("titlemenuseparator", "");
/* :::::::: END Anzeige Dokument / WoTag/ Dat / Uhrzeit ::::::::::::::: */
/*
*********************************************************************************
***** 03. Webbilder direkt übers Kontextmenü im Fx bei Imageshack hochladen *****
*********************************************************************************
*/
/* Bilder bei Imageshack hochladen */
(function() {
var menuAttr = [
{ label: "Bild bei ImageShack hochladen",
id: "context-sendimageTo",
before: "context-sendimage",
url: "imageURL" },
{ label: "Hintergrundbild bei ImageShack hochladen",
id: "context-sendbgimageTo",
before: "context-viewbgimage",
url: "bgImageURL" }
];
for(var i = 0; i < menuAttr.length; i++) {
var menuitem = document.createElement("menuitem");
menuitem.id = menuAttr[i].id;
menuitem.setAttribute("label", menuAttr[i].label);
var beforeId = document.getElementById(menuAttr[i].before);
beforeId.parentNode.insertBefore(menuitem, beforeId.nextSibling);
menuitem.setAttribute("oncommand",
"gBrowser.loadOneTab('http://imageshack.us/transload.php?url=' + " +
"escape(gContextMenu." + menuAttr[i].url + "), " +
"null, null, null, false)")
}
var cm = document.getElementById("contentAreaContextMenu");
cm.addEventListener("popupshowing", function(event) {
gContextMenu.showItem("context-sendimageTo", gContextMenu.onImage);
gContextMenu.showItem("context-sendbgimageTo", gContextMenu.hasBGImage);
}, false);
})();
/*
*********************************************************************************
***** 04. Super DragAndGo *******************************************************
*********************************************************************************
*/
/* :::::::: Drag'n'go (cf. Super DragAndGo) ::::::::::::::: */
contentAreaDNDObserver.onDragOver = function(aEvent, aFlavour, aDragSession) {
aEvent.target.setAttribute("dragover", "true");
return (aDragSession.canDrop = true);
};
contentAreaDNDObserver.__preUC_onDrop = contentAreaDNDObserver.onDrop;
contentAreaDNDObserver.onDrop = function(aEvent, aXferData, aDragSession) {
var url = (/^\s*(.*?)\s*$/m.test(aXferData.data))?RegExp.$1:null;
if (!url)
{
this.__preUC_onDrop(aEvent, aXferData, aDragSession);
return;
}
if (/^file:\/{3}(?:.*\/)?(.+\.xpi)$/.test(url)) // local XPI -> install
{
var xpinstallObj = {};
xpinstallObj[RegExp.$1] = url;
for (var i = 1; i < aDragSession.numDropItems; i++)
{ // allow to install several extensions at once
url = this.__UC_getDroppedURL(aDragSession, i);
if (/^file:\/{3}(?:.*\/)?(.+\.xpi)$/.test(url))
{
xpinstallObj[RegExp.$1] = url;
}
}
InstallTrigger.install(xpinstallObj);
}
else if (/^file:\/{3}|^data:.+|^(?!javascript:)\S*?(([\w-]\.)+\w{2,7}|localhost([:\/]|$))\S*$/.test(url))
{
gBrowser.dragDropSecurityCheck(aEvent, aDragSession, url);
var referrer = gBrowser.currentURI;
if (referrer.spec == "about:blank")
{
loadURI(url, null, null);
}
else
{
this.__UC_loadInTab(url, aEvent);
}
for (i = 1; i < aDragSession.numDropItems; i++)
{
url = this.__UC_getDroppedURL(aDragSession, i);
gBrowser.dragDropSecurityCheck(aEvent, aDragSession, url);
gBrowser.addTab(url, referrer);
}
}
else // text string -> web search
{
try
{
var openURL = gPrefService.getComplexValue("browser.search.defaulturl", Components.interfaces.nsIPrefLocalizedString).data;
}
catch (ex)
{
openURL = "http://www.google.com/search?q=";
}
this.__UC_loadInTab(openURL + encodeURIComponent(url), aEvent);
}
aEvent.preventDefault();
};
contentAreaDNDObserver.__preUC_onDragStart = contentAreaDNDObserver.onDragStart;
contentAreaDNDObserver.onDragStart = function(aEvent, aXferData, aDragAction) {
var target = aEvent.originalTarget;
if (!target.src || target.ownerDocument.defaultView == window)
{
contentAreaDNDObserver.__preUC_onDragStart(aEvent, aXferData, aDragAction);
return;
}
for (var obj = target.parentNode; obj && !obj.href; obj = obj.parentNode);
var url = (obj)?obj.href:target.src;
var caption = ((obj)?obj.title:null) || target.title || target.alt || url.replace(/^.*\//, "") || url;
aXferData.data = new TransferData();
aXferData.data.addDataForFlavour("text/x-moz-url", url + "\n" + caption);
aXferData.data.addDataForFlavour("text/unicode", url);
aXferData.data.addDataForFlavour("text/html", '<a href="' + url + '">' + caption + '</a>');
var nsIDragService = Components.interfaces.nsIDragService;
aDragAction.action = nsIDragService.DRAGDROP_ACTION_COPY | nsIDragService.DRAGDROP_ACTION_MOVE | nsIDragService.DRAGDROP_ACTION_LINK;
};
contentAreaDNDObserver.__UC_loadInTab = function(aURL, aEvent) {
var newTab = gBrowser.addTab(aURL, gBrowser.currentURI);
if (gPrefService.getBoolPref("browser.tabs.loadInBackground") != !(aEvent && aEvent.shiftKey))
{
gBrowser.selectedTab = newTab;
}
};
contentAreaDNDObserver.__UC_getDroppedURL = function(aDragSession, aIndex) {
try
{
var xfer = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
xfer.addDataFlavor("application/x-moz-file", "nsIFile");
xfer.addDataFlavor("text/x-moz-url");
xfer.addDataFlavor("text/unicode");
aDragSession.getData(xfer, aIndex);
var flavour = {}, data = {}, length = {};
xfer.getAnyTransferData(flavour, data, length);
var xferData = new FlavourData(data.value, length.value, this.getSupportedFlavours().flavourTable[flavour.value]);
return transferUtils.retrieveURLFromData(xferData.data, xferData.flavour.contentType);
}
catch (ex)
{
return null;
}
};
getBrowser().addEventListener("dragover", function(aEvent) { nsDragAndDrop.dragOver(aEvent, contentAreaDNDObserver); }, false);
gBrowser.addEventListener("drop", function(aEvent) { nsDragAndDrop.dragOver(aEvent, contentAreaDNDObserver); }, false);
gBrowser.addEventListener("draggesture", function(aEvent) { nsDragAndDrop.startDrag(aEvent, contentAreaDNDObserver); }, true);
/*
*********************************************************************************
***** 05. URL to new tab ********************************************************
***** muss eigentlich zu Punkt 10, geht aber nicht anders,*******************
***** da sonst alles andere deaktiviert wird ********************************
*********************************************************************************
*/
BrowserLoadURL = function new_BrowserLoadURL(aTriggeringEvent, aPostData) {
var url = gURLBar.value;
if (aTriggeringEvent instanceof MouseEvent) {
if (aTriggeringEvent.button == 2) {
return;
}
//openUILink(url, aTriggeringEvent, false, false, true, aPostData);
gBrowser.loadOneTab(url, null, null, aPostData, false, true);
return;
}
if (aTriggeringEvent && aTriggeringEvent.altKey) {
handleURLBarRevert();
content.focus();
gBrowser.loadOneTab(url, null, null, aPostData, false, true);
aTriggeringEvent.preventDefault();
aTriggeringEvent.stopPropagation();
} else {
//loadURI(url, null, aPostData, true);
gBrowser.loadOneTab(url, null, null, aPostData, false, true);
}
focusElement(content);
}
/*
*********************************************************************************
***** 06. Drag'n'Duplicate ******************************************************
*********************************************************************************
*/
/* :::::::: Drag'n'Duplicate ::::::::::::::: */
gBrowser.duplicateTab = function(aTab) {
var ss = Components.classes["@mozilla.org/browser/sessionstore;1"].getService(Components.interfaces.nsISessionStore);
var state = ss.getWindowState(aTab.ownerDocument.defaultView);
state = eval("(" + state + ")");
state.windows[0].tabs = state.windows[0].tabs.splice(aTab._tPos, 1);
ss.setWindowState(window, state.toSource(), false);
return document.getAnonymousElementByAttribute(this, "linkedpanel", this.mPanelContainer.lastChild.id);
};
gBrowser.__preUC_onDrop = gBrowser.onDrop;
gBrowser.onDrop = function(aEvent, aXferData, aDragSession) {
if (aDragSession.sourceNode && aDragSession.sourceNode.localName == "tab")
{
var oldTab = aDragSession.sourceNode;
if (aEvent.ctrlKey)
{
var tab = this.duplicateTab(oldTab);
if (oldTab.parentNode != this.mTabContainer)
{
this.selectedTab = tab;
}
this.moveTabTo(tab, this.getNewIndex(aEvent));
return;
}
if (oldTab.parentNode != this.mTabContainer)
{
this.selectedTab = this.duplicateTab(oldTab);
this.moveTabTo(this.selectedTab, this.getNewIndex(aEvent));
oldTab.ownerDocument.defaultView.gBrowser.removeTab(oldTab);
window.focus();
return;
}
}
gBrowser.__preUC_onDrop(aEvent, aXferData, aDragSession);
};
gBrowser.__preUC_onDragOver = gBrowser.onDragOver;
gBrowser.onDragOver = function(aEvent, aFlavour, aDragSession) {
if (aDragSession.sourceNode && aDragSession.sourceNode.localName == "tab" && aDragSession.sourceNode.parentNode != this.mTabContainer)
{
aDragSession = { canDrop: aDragSession.canDrop, sourceNode: this.selectedTab };
}
this.__preUC_onDragOver(aEvent, aFlavour, aDragSession);
};
/*
*********************************************************************************
***** 07. Paste and Go *************************************************************
*********************************************************************************
*** 07.01. in Tab ***
*/
/*-----------------------------------------------------
Paste and Go in Tab
Add Paste and Go menuitem to tab context menu
to paste URL from clipboard
and load it in current tab or a new tab
Copyright 2006 by LouCypher (aka Zoolcar9)
Released under the GPL license
http://www.gnu.org/licenses/gpl.txt
-----------------------------------------------------*/
(function() {
// create menuitem
var pngTab = document.createElement("menuitem");
pngTab.id = "paste-and-go-in-tab";
pngTab.setAttribute("label", "Paste and Go");
pngTab.setAttribute("oncommand",
"var tabbrowser = getBrowser(); " +
"var paste = readFromClipboard(); " +
"if (!paste) return; " +
"if (tabbrowser.mContextTab.localName == 'tabs') " +
"gBrowser.addTab(paste); " +
"else tabbrowser.mContextTab.linkedBrowser.loadURI(paste);");
// add menuitem to tab context menu
var tabContext = document.getAnonymousElementByAttribute(
gBrowser, "anonid", "tabContextMenu");
tabContext.insertBefore(pngTab, 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 png = document.getElementById("paste-and-go-in-tab");
if (pasteURL) png.tooltipText = readFromClipboard();
png.setAttribute("disabled", !pasteURL ? true : false);
}, false);
var copyTabUrlTMP = document.getElementById("tm-copyTabUrl");
if (copyTabUrlTMP)
tabContext.insertBefore(copyTabUrlTMP, pngTab.nextSibling);
})();
/*** 07.02. in url-bar ***/
/**
* A user script for userChrome.js extension.
* @name Paste and Go
* @description Add 'Paste and Go' command to the context menu in Location bar.
* @compatibility Firefox 2.0
* @author Gomita
* @version 2006.12.16
* @permalink http://amb.vis.ne.jp/mozilla/?p=69
*/
(function()
{
document.getElementById("urlbar").addEventListener("popupshowing", function(event)
{
var menupopup = event.originalTarget;
var refChild = menupopup.getElementsByAttribute("cmd", "cmd_paste")[0];
var canPaste = refChild.getAttribute("disabled") == "true";
var menuitem = document.getElementById("pasteandgo-menuitem");
if (!menuitem)
{
var pasteAndGo = function(event)
{
if (event.type == "click" && event.button != 1)
return;
// paste
goDoCommand("cmd_paste");
// and go
handleURLBarCommand(event);
// close popup
menupopup.hidePopup();
};
menuitem = document.createElement("menuitem");
menuitem.id = "pasteandgo-menuitem"
menuitem.setAttribute("label", "Paste and Go");
menuitem.setAttribute("accesskey", "G");
menuitem.addEventListener("command", pasteAndGo, false);
menuitem.addEventListener("click", pasteAndGo, false);
menupopup.insertBefore(menuitem, refChild.nextSibling);
}
menuitem.setAttribute("disabled", canPaste.toString());
}, false);
})();
/*
*********************************************************************************
***** 08. Progress in Titlebar DEAKTIVIERT *******************************************************
*********************************************************************************
*/
// => LOADER
/*
*********************************************************************************
***** 09. Compact Menu **********************************************************
*********************************************************************************
*/
(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);
})();
/*
*********************************************************************************
***** 10. Status bar in menubar *****************************************************
*********************************************************************************
*/
var statusbar = document.getElementById("status-bar");
var menubar = document.getElementById("toolbar-menubar");
menubar.appendChild(statusbar);
statusbar.setAttribute("style", "-moz-appearance: toolbar;");
statusbar.setAttribute("flex", "1");
/*
*********************************************************************************
***** 11. TABS ******************************************************************
*********************************************************************************
*
***** 11.01. Dropping Tabs Half Step Ahead **************************************
*/
/**
* A user script for userChrome.js extension.
* @name Dropping Tabs Half Step Ahead
* @description [en] Change the position whereon the dragging browser tab is dropped half step ahead.
* @description [ja] ??????????????????????????????????????
* @compatibility Firefox 2.0
* @author Gomita
* @lastupdated 2007.1.21
* @permalink http://amb.vis.ne.jp/mozilla/?p=79
*/
(function()
{
var func = gBrowser.getNewIndex.toString();
func = func.replace("this.mTabs[i].boxObject.width / 2", "this.mTabs[i].boxObject.width");
func = func.replace("return i;", "{ if (i > this.mTabContainer.selectedIndex) i++; return i; }");
eval("gBrowser.getNewIndex = " + func);
})();
/*
***** 11.02. Mouse Wheel on Tab Bar *********************************************
*/
/**
* A user script for userChrome.js extension.
* @name Mouse Wheel on Tab Bar
* @description Change selected tab by mouse wheel on tab bar.
* @compatibility Firefox 2.0
* @author Gomita
* @version 2006.12.23
* @permalink http://amb.vis.ne.jp/mozilla/?p=72
*/
(function()
{
var mouseScrollHandler = function(event)
{
if (event.originalTarget.localName == "menuitem")
return;
event.preventDefault();
event.stopPropagation();
gBrowser.mTabContainer.advanceSelectedTab(event.detail < 0 ? -1 : 1, true);
};
gBrowser.mStrip.addEventListener("DOMMouseScroll", mouseScrollHandler, true);
})();
/*
***** 11.03. Tabs to the Right (cf. Tabs Open Relative) *****************************
*/
/* :::::::: Tabs to the Right (cf. Tabs Open Relative) ::::::::::::::: */
(function() {
getBrowser().__uc_addedTabs = 0;
eval("gBrowser.addTab = " + gBrowser.addTab.toString().replace(/\{/, "$& var __oldTabPos = this.mCurrentTab._tPos;").replace(/return /, "if (!blank) this.moveTabTo(t, __oldTabPos + 1 + this.__uc_addedTabs++); $&"));
eval("gBrowser.moveTabTo = " + gBrowser.moveTabTo.toString().replace(/{/, "$& if (aTab == this.mCurrentTab) this.__uc_addedTabs = 0;"));
gBrowser.mTabContainer.addEventListener("select", function() { gBrowser.__uc_addedTabs = 0; }, false);
})();
/*
***** 11.04. Real-time Tab Preview DEAKTIVIERT **********************************
*/
// ==UserScript==
// @name Real-time Tab Preview
// @namespace http://www.xuldev.org/
// @description Displays a real-time thumbnail preview when hovering mouse on a tab.
// @include main
// @author Gomita
// @version 1.0.20080201
// @homepage http://www.xuldev.org/misc/ucjs.php
// ==/UserScript==
/*
var ucjsTabPreview = {
PREVIEW_WIDTH: 600, // width of preview in pixels // 250
PREVIEW_HEIGHT: 800, // height of preview in pixels // 180
UPDATE_INTERVAL: 10, // interval to refresh preview in milliseconds
_updateTimer: null,
init: function() {
var overlay =
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml">
<popupset id="mainPopupSet">
<tooltip id="TabPreviewTooltip" noautohide="true" orient="vertical"
onpopupshowing="ucjsTabPreview.showPreview();"
onpopuphiding="ucjsTabPreview.cancelTimer();">
<label style="text-align: center;" />
<hbox flex="1">
<html:canvas id="TabPreviewCanvas" width={this.PREVIEW_WIDTH} height={this.PREVIEW_HEIGHT}
style="display: block; border: 1px solid ThreeDLightShadow; padding: 3px;" />
</hbox>
</tooltip>
</popupset>
</overlay>;
overlay = "data:application/vnd.mozilla.xul+xml;charset=utf-8," + encodeURI(overlay.toXMLString());
document.loadOverlay(overlay, null);
getBrowser().mStrip.tooltip = "TabPreviewTooltip";
},
showPreview: function() {
var tn = document.tooltipNode;
if (!tn || tn.localName != "tab")
return;
document.getElementById("TabPreviewTooltip").firstChild.value = tn.label;
var canvas = document.getElementById("TabPreviewCanvas");
var win = gBrowser.getBrowserForTab(tn).contentWindow;
var isBlank = win.location.href == "about:blank";
canvas.parentNode.style.display = isBlank ? "none" : "block";
if (!isBlank) {
var w = win.innerWidth;
var z = canvas.width / w;
var h = canvas.height / z;
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.scale(z, z);
ctx.drawWindow(win, win.scrollX, win.scrollY, w + win.scrollX, h + win.scrollY, "rgb(255,255,255)");
ctx.restore();
}
if (this.UPDATE_INTERVAL > 0) {
var callback = function(self) { self.showPreview(); };
this._updateTimer = window.setTimeout(callback, this.UPDATE_INTERVAL, this);
}
},
cancelTimer: function() {
if (this._updateTimer) {
window.clearTimeout(this._updateTimer);
this._updateTimer = null;
}
}
};
ucjsTabPreview.init();
window.addEventListener("unload", function() { ucjsTabPreview.cancelTimer(); }, false);
*/
/*
***** 11.05. UndoListInTabmenuToo.uc.js *****************************************
*/
// => LOADER
/*
***** 11.06. zzzz-MultiRowTabforFx2.0_3.0_mod1.uc.js ****************************
*/
// => LOADER
/*
***** 11.07. tablock.uc.js ******************************************************
*/
// => LOADER
/*
***** 11.08. tabprotect.uc.js ***************************************************
*/
// => LOADER
/*
***** 11.09. URL to new tab *****************************************************
*/
// siehe Punkt 05.
/*
*********************************************************************************
***** 12. SEARCHING *************************************************************
*********************************************************************************
*
***** 12.01. Clear Search Term **************************************************
*/
// ==UserScript==
// @name Clear Search Term
// @namespace http://www.xuldev.org/
// @description Clears the search term and reset the engine after searching.
// @include main
// @author Gomita
// @version 1.0.20080201
// @homepage http://www.xuldev.org/misc/ucjs.php
// ==/UserScript==
(function() {
var searchbar = document.getElementById("searchbar");
searchbar._doSearchInternal = searchbar.doSearch;
searchbar.doSearch = function(aData, aInNewTab) {
this._doSearchInternal(aData, aInNewTab);
// clear the search term
this.value = "";
// reset the search engine
this.currentEngine = this.engines ? this.engines[0] : this._engines[0];
};
}());
/*
***** 12.02. Scroll Search Engines in contextmenu *******************************
*/
// ==UserScript==
// @name Scroll Search Engines
// @namespace http://www.xuldev.org/
// @description Scrolling mouse wheel on 'Search <engine> for <selection>' menu to change the engine.
// @include main
// @author Gomita
// @version 1.0.20080201
// @homepage http://www.xuldev.org/misc/ucjs.php
// @note Does not work if you don't place the search bar.
// ==/UserScript==
(function() {
var searchMenu = document.getElementById("context-searchselect");
searchMenu.className = "menuitem-iconic";
// update icon when opening context menu
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", function(event) {
if (!gContextMenu || !gContextMenu.isTextSelected)
return;
var ss = Cc["@mozilla.org/browser/search-service;1"]
.getService(Ci.nsIBrowserSearchService);
var engine = document.getElementById("searchbar") ?
ss.currentEngine : ss.defaultEngine;
if (engine.iconURI)
document.getElementById("context-searchselect").setAttribute("src", engine.iconURI.spec);
}, false);
// enable to change the engine with scroll wheel
searchMenu.addEventListener("DOMMouseScroll", function(event) {
var searchBar = document.getElementById("searchbar");
if (!searchBar)
return;
searchBar.selectEngine(event, event.detail > 0);
// update label
var menu = event.originalTarget;
var label = gNavigatorBundle.getFormattedString(
"contextMenuSearchText",
[searchBar.currentEngine.name, getBrowserSelection(16)]
);
menu.setAttribute("label", label);
// update icon
var iconURI = searchBar.currentEngine.iconURI;
if (iconURI)
menu.setAttribute("src", iconURI.spec);
else
menu.removeAttribute("src");
}, false);
// enables to search with middle-click on menu
searchMenu.addEventListener("click", function(event) {
if (event.button == 1) {
event.target.doCommand();
event.target.parentNode.hidePopup();
}
}, false);
}());
/*
***** 12.03. Search Clipboard ***************************************************
*/
// ==UserScript==
// @name Search Clipboard
// @namespace http://www.xuldev.org/
// @description Middle-click the search engine button or popup to search clipboard text.
// @include main
// @author Gomita
// @version 1.0.20080201
// @homepage http://www.xuldev.org/misc/ucjs.php
// ==/UserScript==
(function() {
var searchClipboard = function(event) {
if (event.button != 1)
return;
// get clipboard text
var str = readFromClipboard();
// 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 opening in a new tab or not
var inNewTab = gPrefService.getBoolPref("browser.search.openintab");
inNewTab = ((event && event.altKey) ^ inNewTab);
// load the URL
if (inNewTab) {
var tab = gBrowser.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.stopPropagation();
}
};
var searchbar = document.getElementById("searchbar");
// middle-click the search engine popup to search clipboard
document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-popup")
.addEventListener("click", searchClipboard, false);
// middle-click the search engine button to search clipboard
document.getAnonymousElementByAttribute(searchbar, "anonid", "searchbar-engine-button")
.addEventListener("click", searchClipboard, false);
}());
/*
***** 12.04. contextFindWords ***************************************************
*/
// ==UserScript==
// @name contextFindWords
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description Find In page Selected Words
// @include main
// @compatibility Firefox 2.0 3.0
// @author Alice0775
// @version LastMod 2007/07/31
// @Note
// ==/UserScript==
var contextFind = {
findWords: function() {
var findbar, textbox;
var selected = this._getselection();
var findbar = document.getElementById('FindToolbar');
if('gFindBar' in window && 'onFindAgainCommand' in gFindBar){ //fx3
gFindBar._findField.value = selected;
if(gFindBar.hidden)
gFindBar.onFindCommand();
var evt = document.createEvent("UIEvents");
evt.initUIEvent("input", true, false, window, 0);
gFindBar._findField.dispatchEvent(evt);
}else{ //fx2
textbox = document.getElementById("find-field");
textbox.value = selected;
if(findbar.hidden)
gFindBar.onFindCmd();
gFindBar.find();
}
},
_getFocusedWindow: function(){
var focusedWindow = document.commandDispatcher.focusedWindow;
if (!focusedWindow || focusedWindow == window)
return window._content;
else
return focusedWindow;
},
_getselection: function() {
var targetWindow = this._getFocusedWindow();
var sel = Components.lookupMethod(targetWindow, 'getSelection').call(targetWindow);
// for textfields
if (sel && !sel.toString()) {
var node = document.commandDispatcher.focusedElement;
if (node &&
(node.type == "text" || node.type == "textarea") &&
'selectionStart' in node &&
node.selectionStart != node.selectionEnd) {
var offsetStart = Math.min(node.selectionStart, node.selectionEnd);
var offsetEnd = Math.max(node.selectionStart, node.selectionEnd);
return node.value.substr(offsetStart, offsetEnd-offsetStart);
}
}
return sel ? sel.toString().replace(/\s/g,' ').replace(/^[\ ]+|[\ ]+$/g,'').replace(/[\ ]+/g,' ') : "";
}
}
document.getElementById('contentAreaContextMenu').addEventListener('popupshowing', function(aEvent) {
if(aEvent.originalTarget != document.getElementById('contentAreaContextMenu')) return;
var selected = contextFind._getselection();
if (selected.length > 15) selected = selected.substr(0,15) + "...";
var mitem = document.getElementById("contextFindInPageWords");
if(selected !='' ){
mitem.label="ページ内検索: \"" + selected + "\"";
mitem.setAttribute('hidden', 'false');
}else{
mitem.setAttribute('hidden', 'true');
}
}, false);
/*
***** 12.05.urlbar-splitter *****************************************************
*/
(function() {
var splitter = document.createElement("splitter");
splitter.id = "urlbar-splitter";
splitter.setAttribute("style", "min-width: 0px; " +
"background-color: transparent; " +
"margin: 2px 0; border-width: 0 1px; " +
"border-style: none solid; " +
"border-right-color: threedhighlight; " +
"border-left-color: threedshadow; " +
"-moz-appearance: statusbarpanel;");
splitter.setAttribute("ondblclick", "this.resetWidth(event);");
splitter.resetWidth = function(aEvent) {
var elms = [aEvent.target.previousSibling,
aEvent.target.nextSibling];
for (var i = 0; i < elms.length; i++) {
if (elms[i].hasAttribute('width'))
elms[i].removeAttribute('width');
}
}
var urlbar = document.getElementById("urlbar-container");
urlbar.parentNode.insertBefore(splitter, urlbar.nextSibling);
})();
/*
***** 12.06. addResizerForSearchBar DEAKTIVIERT *********************************
*/
// ==UserScript==
// @name addResizerForSearchBar.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description add Splitter InsertBefore SearchBar
// @include main
// @compatibility Firefox 2.0 only
// @author Alice0775
// @version LastMod 2007/10/01 07:00
// @Note
// ==/UserScript==
/*
(function(){
function makeresizer(){
var splitter = document.createElement("splitter");
splitter.setAttribute("onmouseup","this.getposition(event);");
splitter.setAttribute("id","ResizerForSearchBar");
var searchcontainer = document.getElementById("search-container");
searchcontainer.parentNode.insertBefore(splitter,searchcontainer);
splitter.getposition = function(event){
const PREFID =
'@mozilla.org/preferences;1';
const nsIPrefBranch = Components.interfaces.nsIPrefBranch
const PREF = Components.classes[PREFID].getService(nsIPrefBranch);
var searchcontainer = document.getElementById("search-container");
var width = searchcontainer.width;
PREF.setIntPref('userChrome.searchBar.width',width);
}
splitter.setposition = function(){
const PREFID =
'@mozilla.org/preferences;1';
const nsIPrefBranch = Components.interfaces.nsIPrefBranch
const PREF = Components.classes[PREFID].getService(nsIPrefBranch);
try{
var width = PREF.getIntPref('userChrome.searchBar.width',400);
}catch(e){
var width = 400;
}
var searchcontainer = document.getElementById("search-container");
searchcontainer.width = width;
}
splitter.setposition();
return splitter;
}
var searchcontainer = document.getElementById("search-container");
if(searchcontainer) var splitter = makeresizer();
document.getElementById("cmd_CustomizeToolbars").addEventListener("DOMAttrModified", function(e) {
if (e.attrName == "disabled" && !e.newValue)
var searchcontainer = document.getElementById("search-container");
if(searchcontainer){
var splitter = document.getElementById("ResizerForSearchBar");
if(!splitter) splitter = makeresizer();
searchcontainer.parentNode.insertBefore(splitter,searchcontainer);
}else{
var splitter = document.getElementById("ResizerForSearchBar");
if(splitter) splitter.parentNode.removeChild(splitter);
}
}, false);
})();
*/
/*
***** 12.07. Middle Click & Go on urlbar-icon and searchbar-engine-icon *********
*/
// => LOADER (geht nicht anders, aber so schon!)
/*
*********************************************************************************
***** 13. Copy Tab Info *********************************************************
*********************************************************************************
*/
// ==UserScript==
// @name Copy Tab Info
// @namespace http://www.xuldev.org/
// @description Enables to copy title and URL from right-click menu of a tab.
// @include main
// @author Gomita
// @version 1.0.20080201
// @homepage http://www.xuldev.org/misc/ucjs.php
// ==/UserScript==
(function() {
var htmlEscape = function(s) {
s = s.replace(/&/g, "&");
s = s.replace(/>/g, ">");
s = s.replace(/</g, "<");
s = s.replace(/"/g, """);
return s;
};
var copyTabInfo = function (aAsHTML) {
var tab = document.popupNode;
var title = tab.label;
var url = gBrowser.getBrowserForTab(tab).contentWindow.location.href;
var txt = aAsHTML ?
//'<a href="' + htmlEscape(url) + '">' + htmlEscape(title) + '</a>' :
'[url=' + htmlEscape(url) + '"]' + htmlEscape(title) + '[/url]' :
title + "\n" + url;
Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper)
.copyString(txt);
};
var menuitem1 = document.createElement("menuitem");
menuitem1.setAttribute("label", "Copy Title + URL");
menuitem1.addEventListener("command", function() { copyTabInfo(false); }, false);
var menuitem2 = document.createElement("menuitem");
//menuitem2.setAttribute("label", "Copy Title + URL (HTML)");
menuitem2.setAttribute("label", "Copy Title + URL (BBCode)");
menuitem2.addEventListener("command", function() { copyTabInfo(true); }, false);
setTimeout(function() {
gBrowser.mStrip.childNodes[1].appendChild(document.createElement("menuseparator"));
gBrowser.mStrip.childNodes[1].appendChild(menuitem1);
gBrowser.mStrip.childNodes[1].appendChild(menuitem2);
}, 0);
})();
/*
*********************************************************************************
***** 14. Downloadmanager und Chronik im Tab öffnen *****************************
*********************************************************************************
*
*** 14.01 Window Hook (ist für "DM in Hintergrundtab" nötig etc.) ***
*/
// => LOADER
/*
*********************************************************************************
***** 15. userChrome.xul DEAKTIVIERT ********************************************
*********************************************************************************
*/
/* :::::::: userChrome.xul ::::::::::::::: */
/*
(function() {
var userChrome_xul = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("UChrm", Components.interfaces.nsILocalFile);
userChrome_xul.append("userChrome.xul");
if (userChrome_xul.exists())
{
var fileURL = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile(userChrome_xul);
document.loadOverlay(fileURL, null);
}
})();
*/
/*
*********************************************************************************
***** 16. Sub-Script/XUL Loader *************************************************
*********************************************************************************
*/
/* :::::::: Sub-Script/XUL Loader ::::::::::::::: */
// automatically includes all files ending in .uc.js and .uc.xul from the profile's chrome folder
(function() {
var getURLSpecFromFile = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler).getURLSpecFromFile;
var chromeDir = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("UChrm", Components.interfaces.nsILocalFile);
var files = chromeDir.directoryEntries.QueryInterface(Components.interfaces.nsISimpleEnumerator);
var xul_files = [];
while (files.hasMoreElements())
{
var file = files.getNext().QueryInterface(Components.interfaces.nsIFile);
if (/\.uc\.js$/i.test(file.leafName))
{
setTimeout(function(aFile) {
Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript(getURLSpecFromFile(aFile));
}, 0, file);
}
else if (/(^userChrome|\.uc)\.xul$/i.test(file.leafName))
{
xul_files.push(file);
}
}
setTimeout(function() {
if (xul_files.length > 0)
{
document.loadOverlay(getURLSpecFromFile(xul_files.shift()), null);
setTimeout(arguments.callee, 0);
}
}, 0);
})();
/*
*********************************************************************************
***** 17. Copy Feed URL menuitem ************************************************
*********************************************************************************
*/
// Copy Feed URL menuitem
// by pile0nades (with awesome help from Zoolcar9)
// Right-click the feed icon and click Copy Feed URL
(function() {
var menu = document.getElementById("toolbar-context-menu");
menu.addEventListener("popupshowing", function(event) {
if(event.target.id == "toolbar-context-menu") {
// remove old items before adding new ones
if(document.getElementById("context-copyfeed-number-0-url-separator") != null) {
menu.removeChild(document.getElementById("context-copyfeed-number-0-url-separator"));
}
for(var i=0; document.getElementById("context-copyfeed-number-" + i + "-url") != null; i++) {
menu.removeChild(document.getElementById("context-copyfeed-number-" + i + "-url"));
}
if(document.popupNode.id == "feed-button") {
// add feed items and separator
var feeds = gBrowser.selectedBrowser.feeds;
var mi = [];
for(var i=0; i<feeds.length; i++) {
mi[i] = menu.appendChild(document.createElement("menuitem"));
mi[i].id = "context-copyfeed-number-" + i + "-url";
mi[i].setAttribute("label", (feeds.length == 1 ? "Copy Feed URL" : "Copy URL of '" + feeds[i].title +"'"));
mi[i].setAttribute("oncommand", "cfu_copyFeedURL('" + feeds[i].href + "')");
}
var ms = menu.insertBefore(document.createElement("menuseparator"), mi[0]);
ms.id = mi[0].id + "-separator";
}
}
}, false);
})();
function cfu_copyFeedURL(url) {
var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
gClipboardHelper.copyString(url);
}
/*
*********************************************************************************
***** 18. fixbug253912ShowstheBookmarkstooltips *********************************
*********************************************************************************
*/
// ==UserScript==
// @name fixbug253912ShowstheBookmarkstooltips
// @namespace http://forums.mozillazine.org/viewtopic.php?p=2171524#2171524
// @description Shows the Bookmarks tooltips (bug 253912)
// @include main
// @compatibility Firefox 3.0
// @author Zoolcar9Joined
// @modified Alice0775 for Gecko/2008010508 Minefield/3.0b3pre
// @version 2008/01/06 17:00 ScrapBookã