Hi there francisstokes,
the probable reason for it not working is that you have not allowed the page to load before calling the script.
This means that document.forms[0] does not as yet exist.
Also, for the page to validate you need your form to to be coded either like this...
Code:
<form action="#">
<div id="myform">
</div>
</form>
...or this...
Code:
<form action="#">
<fieldset>
<legend></legend>
</fieldset>
</form>
For the first option use this script...
Code:
<script type="text/javascript">
if(window.addEventListener){
window.addEventListener('load',mytest,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',mytest);
}
}
function mytest(){
// ==UserScript==
// @author Francis Stokes
// @name Recent Shares Ext.
// @namespace rse
// @description Extension to the stanndard Recent Shares Page
// @include http://*.stumbleupon.com/shares/
// ==/UserScript==
tb=document.createElement('input');
tb.setAttribute('type','text');
f=document.getElementById('myform');
f.appendChild(tb);
}
</script>
...and the second use this...
Code:
<script type="text/javascript">
if(window.addEventListener){
window.addEventListener('load',mytest,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',mytest);
}
}
function mytest(){
// ==UserScript==
// @author Francis Stokes
// @name Recent Shares Ext.
// @namespace rse
// @description Extension to the stanndard Recent Shares Page
// @include http://*.stumbleupon.com/shares/
// ==/UserScript==
tb=document.createElement('input');
tb.setAttribute('type','text');
f=document.forms[0][0];
f.appendChild(tb);
}
</script>