0

I do not know if that is possible but I want to change/set a value loaded by a webbrowser.

In this script tag the variables are set:

<script>
Current.set('username','tomi');
Current.set('user_id','1234');


</script>

I tried such a thing and obviously and as expected the following code line does not work :

unsafeWindow.Current.set('username', 'myname');
unsafeWindow.Current.set('user_id', '1111');

How can I manipulate such a code?

Val Nolav
  • 908
  • 8
  • 19
  • 44

2 Answers2

2

There may be a simpler way, depending on the actual target page (link to it) and what you are trying to do. But, you can always use the checkForBadJavascripts utility. Just set your script to run at document-start.

See this answer and this answer.

In this case, you would call checkForBadJavascripts() like so:

function changeUser () {
    Current.set('username', 'myname');
    Current.set('user_id', '1111');

    // ...
}

checkForBadJavascripts ( [
    [   false, 
        /username[\'\", ]+tomi/, 
        function () {addJS_Node (null, null, changeUser);} 
    ]
] );

*COPY checkForBadJavascripts.js contents here.*
Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • I added your code however, it does not work. I am trying to figure out the problem. I check if it start with document starts but it seems it is starting at document-end because document.readyState: interactive. – Val Nolav May 11 '12 at 16:27
  • You marked this answer accepted but the comment says your script's not working? Did you figure it out? You ***set*** your script to run at the start; please read the links in the answer above. If it still doesn't work, put your complete script in the question or link to it and we'll figure out the glitch. – Brock Adams May 11 '12 at 17:44
  • I approved your answer because it makes sense. And I want to show my gratitude to your good answer. I will try for a few more time before I post it here. Thanks! – Val Nolav May 11 '12 at 18:42
0

You can't. Greasemonkey script executes after all other scripts and after page loads.

antyrat
  • 27,479
  • 9
  • 75
  • 76