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?

2 Answers 2

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.*
Sign up to request clarification or add additional context in comments.

3 Comments

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.
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.
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!
0

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

3 Comments

Is there any way around that?
this is for security reasons, @ValNolav . So no, I would not think so
This answer is doubly wrong. Greasemonkey runs before the page finishes loading, by default. And what the OP wants is normally doable as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.