// ==UserScript== // @name Relax Slaves // @namespace Relax Slaves // @include http://www.slavehack.com/index2.php?page=slaves function do_platypus_script() { erase_it(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[3]/CENTER[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null); relax(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[3]/TABLE[1]/TBODY[1]/TR[1]/TD[1]/CENTER[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null); relax(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null); relax(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[3]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null); relax(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[2]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null); relax(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null); relax(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null); }; // Ends do_platypus_script window.addEventListener("load", function() { do_platypus_script() }, false); // // Mon Dec 19 15:59:37 2005 -- Scott R. Turner // Short, uncommented file containing all the code to implement Platypus // actions. Can be "included" into the Platypus script. // // // function walk_down(node, func) { if (node.nodeType == 1) { if (node.tagName != "IMG") func(node); if (node.childNodes.length != 0) for (var i=0; i 0) { doc.body.removeChild(doc.body.childNodes[0]); }; var replacement_div = doc.createElement ("DIV"); replacement_div.setAttribute('style', "margin: 0 2%; text-align: left"); replacement_div.appendChild(node); doc.body.appendChild(replacement_div); }; function set_style_script(doc, element, new_style) { element.setAttribute('style', new_style); }; function modify_single_url(doc, match_re, replace_string, node) { if (node.href) { node.href = node.href.replace(match_re, replace_string); }; }; function do_modify_url_it(doc, node, match_re, replace_string, global_flag) { match_re = new RegExp(match_re); if (global_flag) { var allurls = doc.getElementsByTagName('A'); for(var i = 0, url; url = allurls[i]; i++) modify_single_url(doc, match_re, replace_string, url); } else { modify_single_url(doc, match_re, replace_string, node); }; }; function do_modify_html_it(doc, element, match_re, replace_string) { match_re = new RegExp(match_re); if (element.innerHTML) { element.innerHTML = element.innerHTML.replace(match_re, replace_string); }; }; function relax(doc, node) { walk_down(node, function (node) { node.style.width = 'auto'; node.style.marginLeft = '0pt'; node.style.marginRight = '0pt'; if (node.width) node.width = null; }); } function fix_page_it(doc, node) { doc.background = null; doc.bgColor = "white"; if (doc.style) { doc.style.backgroundColor = "white"; doc.style.backgroundImage = "none"; if (doc.style.color == "white") { doc.style.color = "black"; }; if (doc.text == "white") { doc.text = "black"; }; }; doc.body.background = null; doc.body.bgColor = "white"; if (doc.body.style) { doc.body.style.backgroundColor = "white"; doc.body.style.backgroundImage = "none"; if (doc.body.style.color == "white") { doc.body.style.color = "black"; }; if (doc.body.text == "white") { doc.body.text = "black"; }; }; }; function insertAfter(newNode, target) { var parent = target.parentNode; var refChild = target.nextSibling; if(refChild != null) parent.insertBefore(newNode, refChild); else parent.appendChild(newNode); }; function html_insert_it(doc, element, new_html, before, insert_as_block) { var new_element; if (insert_as_block) { new_element = doc.createElement ("DIV"); } else { new_element = doc.createElement ("SPAN"); }; new_element.innerHTML = new_html; if (before) { element.parentNode.insertBefore(new_element, element); } else { insertAfter(new_element, element); }; }; function auto_repair_it(doc, node) { var biggest_elem = find_biggest_elem(doc); isolate(doc, biggest_elem); relax(doc, biggest_elem); make_bw(doc, biggest_elem); fix_page_it(doc, biggest_elem); }; function find_biggest_elem(doc) { const big_element_limit = 0.25; var size_of_doc = doc.documentElement.offsetHeight * doc.documentElement.offsetWidth; var body = doc.body; var size_of_body = body.offsetHeight * body.offsetWidth; if (size_of_body < (0.80 * size_of_doc)) { size_of_body = size_of_doc; }; var max_size = 0; var max_elem = doc; var allElems = document.evaluate("//*", doc.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < allElems.snapshotLength; i++) { var thisElem = allElems.snapshotItem(i); var thisElem_size = thisElem.offsetHeight * thisElem.offsetWidth; if (thisElem_size < size_of_body && thisElem_size > max_size && !contains_big_element(thisElem, size_of_body * big_element_limit)) { max_size = thisElem_size; max_elem = thisElem; }; }; return max_elem; }; function contains_big_element(node, limit) { if (node.childNodes.length != 0) for (var i=0; i limit) return true; }; return false; }; function platypus_do(win, func_name, o, other, other2, other3) { var func = eval(func_name); var doc = null; if (func == null) return; if (!o) { Warning("Platypus couldn't find a page element when executing the command "+ func_name+". This usually happens when running a script -- maybe the"+ " web page the script is running on has changed."); }; doc = win.document; func(doc, o, other, other2, other3); }; //.user.js