scripting - Find all instances of 'old' in a webpage and replace each with 'new', using a javascript bookmarklet -
Whatever I have to do, all instances of 'old' are included in a web page with 'new' Change in bookmarklet or GreeceCookie script How can I do this? I think jQuery or other framework is fine because they have hacks to include both the notebooks as well as the grayscenic scripts.
A function that is clozer-proof does not mean that it does not just make any tags or attributes Will touch
function htmlreplace (a, b, element) {if (! Element) element = document.body; Var node = element.childNodes; (Var n = 0; n & lt; nodes.length; n ++) {if (nodes [n] .nodeType == Node.TEXT_NODE) {var r = New RegExp (a, 'gi'); Nodes [n] .textcontent = nodes [n] .textcontent.replace (r, b); } Else {htmlreplace (A, B, node [n]); }}} Htmlreplace ('a', 'r');
bookmarked version:
javascript: function htmlreplace (a, b, element) {if (! Element) element = document.body; Var nodes = Element.childNodes; (Var n = 0; n & lt; nodes.length; n ++) {if (nodes [n] .nodeType == node.TEXTNONDE {nodes [n] .textContent = nodes [n] .textContent.replace ( New RegExp (a, 'gi'), b);} and {htmlreplace (a, b, nodes [n]);}}} htmlreplace ('old', 'new');
Comments
Post a Comment