User:Cryptic/toggleundelete.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Firefox/Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
//<pre><nowiki> function toggle_undelete() { var f = document.getElementById("undelete"); if (f) { var inputs = f.getElementsByTagName("input"); var i; for (i = 0; i < inputs.length; ++i) if (inputs[i].type == "checkbox") inputs[i].checked = !inputs[i].checked; } } function setup_toggle_undelete() { if (document.title == "View and restore deleted pages - Wikipedia, the free encyclopedia") { var f = document.getElementById("undelete"); if (f) { var h2 = f.getElementsByTagName("h2")[0]; if (h2) { var button = document.createElement('input'); button.type = "button"; button.value = "Invert"; button.setAttribute('onClick', 'toggle_undelete()'); f.insertBefore(button, h2); } } } } addOnloadHook(setup_toggle_undelete); //</nowiki></pre>