By LouCypher
Has 84 other scripts.
// ==UserScript==
// @name AMO to FoxieWire
// @namespace http://zoolcar9.lhukie.net/greasemonkey
// @include https://addons.mozilla.org/*
// @exclude https://addons.mozilla.org/*/addons/versions/*
// @description Submit add-on page on AMO to FoxieWire news site
// ==/UserScript==
var divs = getXPathNodeList("//div[@class='install-container']");
if (!divs.snapshotLength) return;
var div, xpiButts, xpiButt, n, foxieButt, img, addonURL, addonId, appName;
var amoURL = "https://addons.mozilla.org/";
var foxieURL = "http://www.foxiewire.com/submit.php" +
"?sourceid=Amo+to+FoxieWire&url=";
for (var i = 0; i < divs.snapshotLength; i++) {
try {
addonURL = getXPathNodeList("//*[@class='name']/a[@href]").
snapshotItem(i).href;
} catch(ex) {
addonURL = location.href;
}
addonId = addonURL.match(/\d+/).toString();
appName = addonURL.match(/([^\/]+)/g)[3].toString();
xpiButts = getXPathNodeList(".//a[starts-with(@id, 'installTrigger')]",
divs.snapshotItem(i));
n = 0;
for (var j = 0; j < xpiButts.snapshotLength; j++) {
xpiButt = xpiButts.snapshotItem(j);
if (xpiButt.parentNode.style.display != "none") {
n++;
foxieButt = xpiButt.parentNode.appendChild(xpiButt.cloneNode(true));
while (foxieButt.hasAttributes()) {
foxieButt.removeAttribute(foxieButt.attributes[0].name);
}
getStrong(foxieButt).removeChild(getStrong(foxieButt).firstChild);
getStrong(foxieButt).style.textAlign = "center";
getStrong(foxieButt).style.width = getComputedStyle(getStrong(xpiButt),
"").width;
img = getStrong(foxieButt).appendChild(document.createElement("img"));
img.src = "data:image/png;base64,\
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZ\
G9iZSBJbWFnZVJlYWR5ccllPAAAA19JREFUeNpEk1toHFUYx79zZs7Mzs5u9pJ03U2ybL\
qpSbDFKm0ERRCFYrFg8cVC8UXpU6EvPvRVFEEfvKC+KiiKD6JYEO+KICilMTG2pWyjCYl\
ht7vZ3exl7jPn4pkNXQ/Mg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.align = "left";
getStrong(foxieButt).appendChild(document.createTextNode("FoxieWire"));
foxieButt.href = foxieURL + escape(amoURL + appName +
"/addon/" + addonId);
foxieButt.title = "Submit to FoxieWire";
foxieButt.addEventListener("click", submitToFoxieWire, false);
}
if (n > 1) {
xpiButts.snapshotItem(j-1).parentNode.removeChild(
xpiButts.snapshotItem(j-1).parentNode.lastChild);
divs.snapshotItem(i).parentNode.parentNode
.style.minHeight = getComputedStyle(divs.snapshotItem(i), "").height;
}
}
}
GM_addStyle(".install-button a:not([id]),\n\
.exp .install-button a:not([id]),\n\
.exp-loggedout .install-button a:not([id]) {\n\
color: #062445 !important;\n\
background-color: #7cc11c !important;\n\
background-image: url(/img/installbtn-bg.png) !important;\n\
}\n\
.exp .install-button a:not([id] span,\n\
.exp .install-button a:not([id] span span,\n\
.exp .install-button a:not([id] span span span,\n\
.exp .install-button a:not([id] span span span strong,\n\
.exp-loggedout .install-button a:not([id] span,\n\
.exp-loggedout .install-button a:not([id] span span,\n\
.exp-loggedout .install-button a:not([id] span span span,\n\
.exp-loggedout .install-button a:not([id] span span span strong {\n\
background-image: url(/img/installbtn-edges-list.png) !important;\n\
}\n\
.install-button a:hover:not([id]),\n\
.install-button a:focus:not([id]),\n\
.install-button a:active:not([id],\n\
.exp .install-button a:hover:not([id]),\n\
.exp .install-button a:focus:not([id]),\n\
.exp .install-button a:active:not([id],\n\
.exp-loggedout .install-button a:hover:not([id]),\n\
.exp-loggedout .install-button a:focus:not([id]),\n\
.exp-loggedout .install-button a:active:not([id]) {\n\
}");
function getXPathNodeList(aXPath, aRoot) {
return document.evaluate(aXPath, aRoot ? aRoot : document, null, 6, null);
}
function getStrong(aNode) { // funny function name
return aNode.getElementsByTagName("strong")[0];
}
function submitToFoxieWire(aEvent) {
aEvent.preventDefault();
GM_openInTab(this.href);
}