Re: [greasemonkey-users] Inject in a specific place

60 views
Skip to first unread message

Anthony Lieuallen

unread,
Apr 8, 2013, 11:06:09 AM4/8/13
to greasemon...@googlegroups.com
You cannot inject in the middle of JavaScript.  JS is single threaded; while it's running no other JS is running.  Attempting to change an existing JS function somewhere in the middle is somewhere from very advanced to impossible to do.  When it is possible, there is no one recipe answer as to how to make it happen, rather you must really know what you're doing and approach that problem specifically.

(You _might_ be able to use document-start and watch [1] or proxies to override definition of the function.  But it's still hard/avanced.)

[1] https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/watch



On Mon, Apr 8, 2013 at 10:28 AM, Osama Muhammed <xxvii...@gmail.com> wrote:
Hey guys, I've had had many ideas to create and everytime i think of it, this thing stops me..
I need an option that lets me select the injection line or something ? i know theres an option to inject on top or bottom but thats not gonna solve it, sometimes i want to edit a javascript function contents and its in middle, it gets called right after it, and if i try to change that function from bottom its useless cus it was already fired, if i tried from top, the middle function will override it,

Anyway close solution for this ? i just started using it not sure

--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to greasemonkey-us...@googlegroups.com.
To post to this group, send email to greasemon...@googlegroups.com.
Visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Osama Muhammed

unread,
Apr 8, 2013, 11:23:01 AM4/8/13
to greasemon...@googlegroups.com
but its possible suggestion isn't it ? as i explained, an option that is like // @append-to-line 11
that injects my js to that line


On Monday, April 8, 2013 5:06:09 PM UTC+2, Anthony Lieuallen wrote:
You cannot inject in the middle of JavaScript.  JS is single threaded; while it's running no other JS is running.  Attempting to change an existing JS function somewhere in the middle is somewhere from very advanced to impossible to do.  When it is possible, there is no one recipe answer as to how to make it happen, rather you must really know what you're doing and approach that problem specifically.

(You _might_ be able to use document-start and watch [1] or proxies to override definition of the function.  But it's still hard/avanced.)

[1] https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/watch

On Mon, Apr 8, 2013 at 10:28 AM, Osama Muhammed <xxvii...@gmail.com> wrote:
Hey guys, I've had had many ideas to create and everytime i think of it, this thing stops me..
I need an option that lets me select the injection line or something ? i know theres an option to inject on top or bottom but thats not gonna solve it, sometimes i want to edit a javascript function contents and its in middle, it gets called right after it, and if i try to change that function from bottom its useless cus it was already fired, if i tried from top, the middle function will override it,

Anyway close solution for this ? i just started using it not sure

--
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to greasemonkey-users+unsub...@googlegroups.com.

Anthony Lieuallen

unread,
Apr 8, 2013, 11:51:39 AM4/8/13
to greasemon...@googlegroups.com
On Mon, Apr 8, 2013 at 11:23 AM, Osama Muhammed <xxvii...@gmail.com> wrote:
but its possible suggestion isn't it ? as i explained, an option that is like // @append-to-line 11
that injects my js to that line


No.  I explicitly said that it is not possible.  You'd need something besides Greasemonkey like perhaps a tampering proxy to do such an action.

Zulkarnain K.

unread,
Apr 8, 2013, 2:27:05 PM4/8/13
to Greasemonkey Users
You can use 'beforescriptexecute' event
https://developer.mozilla.org/docs/DOM/Mozilla_event_reference/beforescriptexecute

Explanations on http://userscripts.org/scripts/show/125936
> --
> You received this message because you are subscribed to the Google Groups
> "greasemonkey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to greasemonkey-us...@googlegroups.com.
> To post to this group, send email to greasemon...@googlegroups.com.
> Visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Zulkarnain K.
https://twitter.com/zoolcar9
https://userscripts.org/users/12

Osama Muhammed

unread,
Apr 9, 2013, 5:34:35 PM4/9/13
to greasemon...@googlegroups.com
I LOVE YOU, that was so helpful. hope it works with chrome as well

in fact, i used afterscriptexecute it was simpler to override variables values and write my own, thanks


On Monday, April 8, 2013 8:27:05 PM UTC+2, Zulkarnain K. wrote:
You can use 'beforescriptexecute' event
https://developer.mozilla.org/docs/DOM/Mozilla_event_reference/beforescriptexecute

Explanations on http://userscripts.org/scripts/show/125936

On Mon, Apr 8, 2013 at 10:51 PM, Anthony Lieuallen <aran...@gmail.com> wrote:
> On Mon, Apr 8, 2013 at 11:23 AM, Osama Muhammed <xxvii...@gmail.com>
> wrote:
>>
>> but its possible suggestion isn't it ? as i explained, an option that is
>> like // @append-to-line 11
>> that injects my js to that line
>
>
>
> No.  I explicitly said that it is not possible.  You'd need something
> besides Greasemonkey like perhaps a tampering proxy to do such an action.
>
> --
> You received this message because you are subscribed to the Google Groups
> "greasemonkey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Zulkarnain K.

unread,
Apr 10, 2013, 12:45:23 AM4/10/13
to Greasemonkey Users
On Wed, Apr 10, 2013 at 4:34 AM, Osama Muhammed <xxvii...@gmail.com> wrote:
>
> hope it works with chrome as well
>


Unfortunately not
https://bugs.webkit.org/show_bug.cgi?id=91463

--
Zulkarnain K.
https://twitter/zoolcar9
https://userscripts.org/users/ 12

Osama Muhammed

unread,
Apr 10, 2013, 9:40:55 AM4/10/13
to greasemon...@googlegroups.com
any alternative functions for chrome ?
Reply all
Reply to author
Forward
0 new messages