There are 17 previous versions of this script.
(function () {
/* ***************************************************************************
User defined configurable variables
------------------------------------------------------------------------ */
const alwaysSameBase = false; // NOTE: Change this to true to force the same selected base theme on every users page.
const alwaysSameCustom = false; // NOTE: Change this to true to force the same selected use of custom CSS on every users page.
const disableUserscriptCSS = false; // NOTE: Change this to true to eliminate CSS styling in this user script.
/* ------------------------------------------------------------------------ */
// ***************************************************************************
// ==UserScript==
// @name Multiply - Theme Sticker
// @namespace http://userscripts.org/users/37004
// @description Toggles viewing of base theme and custom.css, and persists them across browser sessions.
// @copyright 2008+, Marti Martz (http://userscripts.org/users/37004)
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @license Creative Commons; http://creativecommons.org/licenses/by-nc-nd/3.0/
// @version 0.1.6
// @include http://*.multiply.com/*
// @exclude http://images.multiply.com/*
// @exclude http://images.*.multiply.com/*
// @require http://usocheckup.dune.net/42758.js?maxage=7
// ==/UserScript==
/*
CHANGELOG
=========
http://userscripts.org/topics/23549
*/
// ***************************************************************************
function getNick () {
var matches = location.href.match(/http:\/\/(.+).multiply.com\/.*/i);
if (matches)
return matches[1];
}
// ***************************************************************************
function getBase () {
var xpr = document.evaluate(
"//link[@rel='stylesheet'][@type='text/css'][contains(@href,'/style/custom/')]",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
null
);
if (xpr && xpr.singleNodeValue) {
var thisNode = xpr.singleNodeValue;
var matches = thisNode.href.match(/http:\/\/multiply.com\/style\/custom\/(.+)\/\d+.css/i);
if (matches)
return matches[1];
}
return undefined;
}
// ***************************************************************************
function getCustom () {
var xpr = document.evaluate(
"//link[@rel='stylesheet'][@type='text/css'][contains(@href,'/style-custom/')]",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
null
);
if (xpr && xpr.singleNodeValue) {
var thisNode = xpr.singleNodeValue;
var regex = new RegExp("http://" + userNick + ".multiply.com/style-custom/" + userNick + "/(.+)/custom.css", "i");
return thisNode.href.match(regex)[1];
} else {
return "";
}
}
// ***************************************************************************
function setIcon (thisNode, thisBase, thisImage) {
if (!disableUserscriptCSS) {
if (thisNode)
switch (thisBase) {
case "clean":
case "default":
case "whiteout":
thisNode.style.background = "transparent url(" + thisImage + ") no-repeat scroll left top";
break;
default:
thisNode.style.background = "";
break;
}
}
}
// ***************************************************************************
function stickBase (ev) {
try {
ev.stopPropagation();
var newBase = ev.target.value;
} catch (e) {
var newBase = ev;
}
var xpr = document.evaluate(
"//link[@rel='stylesheet'][@type='text/css'][contains(@href,'style/custom/')]",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
null
);
if (xpr && xpr.singleNodeValue) {
var thisNode = xpr.singleNodeValue;
var currentBase = thisNode.href.match(/http:\/\/multiply.com\/style\/custom\/(.+)\/\d+.css/i)[1];
if (currentBase != newBase) {
if (newBase == "") {
try {
if (alwaysSameBase) GM_deleteValue("useBase"); else GM_deleteValue(userNick + ".useBase");
} catch (e) {
if (alwaysSameBase) GM_setValue("useBase", ""); else GM_setValue(userNick + ".useBase", "");
}
location.reload();
} else {
setIcon(document.getElementById("show-custom"), newBase, imageCustom);
setIcon(document.getElementById("hide-custom"), newBase, imageCustom);
setIcon(document.getElementById("view-base"), newBase, imageBase);
if (alwaysSameBase)
GM_setValue("useBase", newBase);
else
GM_setValue(userNick + ".useBase", newBase);
thisNode.href = thisNode.href.replace(currentBase, newBase);
}
}
}
}
// ***************************************************************************
function hideCSS (ev) {
if (ev)
ev.stopPropagation();
var xpr = document.evaluate(
"//link[@rel='stylesheet'][@type='text/css'][contains(@href,'/style-custom/')]",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
null
);
if (xpr && xpr.singleNodeValue) {
var thisNode = xpr.singleNodeValue;
thisNode.parentNode.removeChild(thisNode);
var listitemNode;
listitemNode = document.getElementById("show-custom");
listitemNode.style.display = "list-item";
listitemNode = document.getElementById("hide-custom");
listitemNode.style.display = "none";
if (alwaysSameCustom)
GM_setValue("useCustom", false); else GM_setValue(userNick + ".useCustom", false);
}
}
// ***************************************************************************
function showCSS (ev) {
if (ev)
ev.stopPropagation();
try {
if (alwaysSameCustom)
GM_deleteValue("useCustom"); else GM_deleteValue(userNick + ".useCustom");
} catch (e) {
if (alwaysSameCustom)
GM_setValue("useCustom", true); else GM_setValue(userNick + ".useCustom", true);
}
var xpr = document.evaluate(
"//link[@rel='stylesheet'][@type='text/css'][contains(@href,'/custom/')]",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
null
);
if (xpr && xpr.singleNodeValue) {
var thisNode = xpr.singleNodeValue;
var linkNode = document.createElement("link");
linkNode.rel = "stylesheet";
linkNode.type = "text/css";
linkNode.href = "http://" + userNick + ".multiply.com/style-custom/" + userNick + "/custom.css";
thisNode.parentNode.insertBefore(linkNode, thisNode.nextSibling);
var listitemNode;
listitemNode = document.getElementById("show-custom");
listitemNode.style.display = "none";
listitemNode = document.getElementById("hide-custom");
listitemNode.style.display = "list-item";
} else {
location.reload();
}
}
// ***************************************************************************
function main () {
var xpr = document.evaluate(
"//div[@id='rail']/*/ul[@class='sidelist']",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
null
);
if (xpr && !xpr.singleNodeValue) {
document.evaluate(
"//div[@id='rail']/*/div[@class='railsep']",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
xpr
);
if (xpr && xpr.singleNodeValue) {
thisNode = xpr.singleNodeValue.nextSibling;
var ulistNode = document.createElement("ul");
ulistNode.className = "sidelist";
thisNode.parentNode.insertBefore(ulistNode, thisNode);
var breakNode = document.createElement("br");
thisNode.parentNode.insertBefore(breakNode, thisNode);
}
}
document.evaluate(
"//link[@rel='stylesheet'][@type='text/css'][contains(@href,'/style-custom/')]",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
xpr
);
if (xpr && xpr.singleNodeValue) {
document.evaluate(
"//ul[@class='sidelist']",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
xpr
);
if (xpr && xpr.singleNodeValue) {
thisNode = xpr.singleNodeValue;
var textNode = document.createTextNode("Show " + userNick + "'s custom theme");
var anchorNode = document.createElement("a");
anchorNode.href = "javascript:void(0);";
anchorNode.addEventListener("click", showCSS, true);
var listitemNode = document.createElement("li");
listitemNode.id = "show-custom";
listitemNode.className = "custom";
listitemNode.style.display = "none";
setIcon(listitemNode, userBase, imageCustom);
anchorNode.appendChild(textNode);
listitemNode.appendChild(anchorNode);
thisNode.insertBefore(listitemNode, thisNode.firstChild);
textNode = document.createTextNode("Hide " + userNick + "'s custom theme");
anchorNode = document.createElement("a");
anchorNode.href = "javascript:void(0);";
anchorNode.addEventListener("click", hideCSS, true);
listitemNode = document.createElement("li");
listitemNode.id ="hide-custom";
listitemNode.className = "custom";
listitemNode.style.display = "list-item";
setIcon(listitemNode, userBase, imageCustom);
anchorNode.appendChild(textNode);
listitemNode.appendChild(anchorNode);
thisNode.insertBefore(listitemNode, thisNode.firstChild);
}
var customCSS = (alwaysSameCustom) ? GM_getValue("useCustom") : GM_getValue(userNick + ".useCustom");
if (customCSS != undefined) {
if (customCSS == false) {
hideCSS();
} else {
try {
if (alwaysSameCustom) GM_deleteValue("useCustom"); else GM_deleteValue(userNick + ".useCustom");
} catch (e) {}
}
}
}
document.evaluate(
"//ul[@class='sidelist']",
document,
null,
XPathResult.ANY_UNORDERED_NODE_TYPE,
xpr
);
if (xpr && xpr.singleNodeValue) {
thisNode = xpr.singleNodeValue;
listitemNode = document.createElement("li");
listitemNode.id = "view-base";
listitemNode.className = "vbase";
setIcon(listitemNode, userBase, imageBase);
var thatNode = document.getElementById("show-custom");
if (thatNode)
thisNode.insertBefore(listitemNode, thatNode.nextSibling);
else
thisNode.insertBefore(listitemNode, thisNode.firstChild);
var spanNode = document.createElement("span");
spanNode.className = "slisttxt";
textNode = document.createTextNode("View with");
spanNode.appendChild(textNode);
listitemNode.appendChild(spanNode);
breakNode = document.createElement("br");
breakNode.className = "slisttxt";
listitemNode.appendChild(breakNode);
var selectNode = document.createElement("select");
selectNode.id = "stick-list";
selectNode.className = "slist";
selectNode.title = "Click to view with this base theme.";
selectNode.style.width = "100%";
selectNode.size = 1;
selectNode.addEventListener("change", stickBase, true);
listitemNode.appendChild(selectNode);
var optionNode;
for (var i = themeBase.length - 1; i >= 0; --i) {
optionNode = document.createElement("option");
optionNode.value = themeBase[i][0];
optionNode.text = themeBase[i][1];
optionNode.title = themeBase[i][2];
selectNode.appendChild(optionNode);
}
breakNode = document.createElement("br");
breakNode.className = "slisttxt";
listitemNode.appendChild(breakNode);
var spanNode = document.createElement("span");
spanNode.className = "slisttxt";
textNode = document.createTextNode("base theme");
spanNode.appendChild(textNode);
listitemNode.appendChild(spanNode);
var useBase = (alwaysSameBase) ? GM_getValue("useBase") : GM_getValue(userNick + ".useBase");
if (useBase != undefined) {
if (useBase != "") {
stickBase(useBase);
for (var i = selectNode.length - 1; i >= 0; --i)
if (selectNode[i].value == useBase) {
selectNode.selectedIndex = i;
break;
}
if (useBase == userBase && !alwaysSameBase) {
try {
GM_deleteValue(userNick + ".useBase");
} catch (e) {
GM_setValue(userNick + ".useBase", "");
}
}
} else {
try {
if (alwaysSameBase) GM_deleteValue("useBase"); else GM_deleteValue(userNick + ".useBase");
} catch (e) {}
}
}
}
}
if (top.location != location)
return;
const userNick = getNick();
const userBase = getBase();
const userCustom = getCustom();
const themeBase = [
["independence", "Independence", "[500]"],
["bloodyromance", "Bloody Romance", "[500]"],
["dancewithme", "Dance With Me", "[500]"],
["bacchus", "Bacchus", "[500]"],
["mod", "MOD", "[500]"],
["livelovelaugh", "Live Love Laugh", "[500]"],
["japanese", "Japanese Minimalist", "[500]"],
["whiteout", "Whiteout", "[500]"],
["shadowbox", "Shadow Box", "[500]"],
["redfrog", "Red Frog", "{400]"],
["avlack", "Avlack", "[500]"],
["outburst", "Outburst", "[500]"],
["retro", "Retro", "{400]"],
["blacklily", "Black Lily (wide)", "[500]"],
["petals", "Petals", "[400]"],
["sand", "Sandskrit", "[400]"],
["melon", "Melon", "[400]"],
["mykonos", "Mykonos", "[400]"],
["skyline", "Skyline (wide)", "[500]"],
["basecamp", "Basecamp (wide)", "[500]"],
["blocks", "Blocks", "[500]"],
["blueslate", "Blue Slate", "[500]"],
["newspaper", "Newspaper", "[400]"],
["oasis", "Oasis (wide)", "[500]"],
["classic", "Classic (wide)", "[500]"],
["notebook", "Notebook", "[500]"],
["default", "Andros", "[600]"],
["clean", "Clean", "[600]"],
["", userNick + "'s", "Use this to force a window reload"]
];
for (var i = themeBase.length - 1; i >= 0; --i)
if (themeBase[i][0] == userBase) {
themeBase[i][1] += "*";
themeBase[i][2] += "This is the user selected base theme";
break;
}
const imageCustom = "data:image/png;base64,"
+ 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dE'
+ 'AP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kBBgUIIvqcmCwAAADb'
+ 'SURBVDjLY2CgEDAyMDAwzDxz5j+y4NVjx45PysuzIsYAJmyCn9+/lybWBUyUeoFiA1gYGBgY'
+ 'Xr58iSLIKybGO/PMmUJksf0rVy5b0d39EqsBT548QREUl5QUZGBg6EMWu3DwIAMDA0P/4AsD'
+ 'JqokJEt7IZSEJKZlxyBr5o+iUFFe/j0PH99nGP/OhQtPu1NSrFgYGBgYfn15h6L49/cvDL9+'
+ '/UIRY+PgEGRgYBCE8T+9eyc3iBISAwPvUwYGFnj6//HxF8P7+/dRFD78+5eBhYUFzn//+DED'
+ 'VQAAXIc+lrftEboAAAAASUVORK5CYII=';
const imageBase = "data:image/png;base64,"
+ 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dE'
+ 'AP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9kBBw8qDDTTMXAAAAJM'
+ 'SURBVDjLrZPNS5RRFMafc+59Z5wZGj8SqkkxjXFE+q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