Forum:Automatic text edit on page load?

If one wanted to configure some JavaScript so that it would always first check if there was a piece of code in the wiki source, and if it is not present, plug it in on edit, how would one do that? For instance, when someone goes to "action=edit", check if the text box has "fooBar, Quok.", and if it doesn't, add it to the end of the page. What would the JavaScript for this look like? (sorry, every time I try scripting, I phail...) Ti m e ro o t T • C • E 09:50, 30 June 2009 (UTC)


 * As starting point:

if (wgAction == 'edit' || wgAction == 'submit') { $(appendWikiText); }

function appendWikiText{ var tb = document.getElementById('wpTextbox1'); var text = "fooBar, Quok."; if (tb && tb.value.indexOf(text) == -1) { tb.value += text; } }
 * --Ciencia Al Poder (talk) -WikiDex 18:18, 30 June 2009 (UTC)