GreaseMonkey, which is initially involved, and explores its differences with Opera UsersJS

Source: Internet
Author: User

GreaseMonkey has been disabled for a while on FF.
I discussed the browser plug-in with vanilla a few days ago. I mentioned this monkey and took the time to test it.

I have a general impression on GM:

 

This stuff is essentially block JS.
At the browser level, after parsing the page, it drops a piece of js into the page to run it.
When this js is running, you can add, delete, modify, and query the DOM on the page to achieve the desired results.

Probably because of security concerns, GM js seems to have its own space (sand-box ?)
You cannot directly modify the JS variables and functions of the original page, unless you use unsafeWindow to change the variables and functions of the original page.

 

For this reason,I cannot fix errors that occurred during the loading of the original webpage and some undefined variables..
I cannot control the actions during the loading process.

 

For details about unsafewindow, refer:
Http://suddymail.org/show-165-1.html
Http://lifegoo.pluskid.org /? P = 113

 

I haven't found a solution to this problem yet, but Opera gave me some hope...

 

USERJS of opera

 

Operachina describes the execution principle of USERJS as follows:

 

When a browser loads pages, webpages, scripts, styles, and images are successively loaded. However, the user script has been executed before the first script on the page is executed. Because it is the first script to be executed, it gets control early. It can:

* Determine which external JavaScript files can be loaded on the browsed page;
* Rewrite any script (<SCRIPT>) block code on the loaded webpage;
* Blocks events being detected on the page to change the event handling method;
* Replace the variables and functions defined in the web scripts;

In addition, user scripts can also be used as part of the web pages to be viewed. Including detecting events, creating variables, creating functions, and reading cookies applied to pages. A user script can have such high control, relying entirely on its support from the Opera kernel and the ability to obtain such features, it is also extended to the Opera Mini and Opera Mobile platforms.

 

According to the description, the user script is executed before the page is loaded, so you can do something before loading.

 

However, this is not the case. The user script is executed first, but the initialization variables and functions are the same, later, I will not overwrite the variables and functions with the same name on the page.

 

Opera designers certainly think of this, so they provide many related interfaces, such as the following two:

Window. Opera. definemagicvariable (targetvariablename, fun1, fun2)

Window. Opera. definemagicfunction (targetfunctionname, fun1)

 

I will not re-post the details of these two "Magic interfaces". I will not post any details I have not studied.

If you are interested, click here for viewing.

 

 

I think my problem may be solved on opera through these interfaces?

 

Take the time to continue the study...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.