Chrome extension, 2 of APP Development Study Notes --- spoof Baidu, chrome2 ---

Source: Internet
Author: User

Chrome extension, 2 of APP Development Study Notes --- spoof Baidu, chrome2 ---

Chrome extension, 2 of APP Development Study Notes

Spoof Baidu

We have introduced a simple chrome extension clock. Now I will introduce a chrome extension program that spoof Baidu.

As mentioned above, the manifest. json file is used to describe this extension, which is the entrance of the entire extension and also tells chrome how to handle this extension.

Spoof Baidu:

Next we will write an extension program that spoof Baidu, hoping to have a better understanding of chrome expansion from this instance. First, let's take a look at the expansion effect, such:

We can guess that its function is to prevent you from clicking the Baidu button.

Create a new folder named "egao_baidu ). Create a new menifest. json file in the folder.

Next, let's take a look at the content of the menifest. json file.

{"Manifest_version": 2, "name": "Search buttons that are never clicked", "version": "1.0", "description ": "You will never be able to click the baidu search button", "content_scripts": [{"matches": ["*: //"], // match any of the following content: // if your webpage is subject to URL matching, the script file will automatically execute "js": ["js/haha. js "] // the script file here is haha. js}]}

Let's take a look at some of Baidu's html source file information:

From the content of the source file, Baidu's id is su, and the following shows how to use haha. js.

From the above manifest. json file content, the main attraction is haha. js. Let's take a look at the content of this file.

Function btn_move (el, mouseLeft, mouseTop) {var leftRnd = (Math. random ()-0.5) * 20; var topRnd = (Math. random ()-0.5) * 20; var btnLeft = mouseLeft + (leftRnd> 0? 100:-100) + leftRnd; var btnTop = mouseTop + (topRnd> 0? 30:-30) + topRnd; btnLeft = btnLeft <100? (BtnLeft + window. innerWidth-200) :( btnLeft> window. innerWidth-100? BtnLeft-window.innerWidth + 200: btnLeft); btnTop = btnTop <100? (BtnTop + window. innerHeight-200) :( btnTop> window. innerHeight-100? BtnTop-window.innerHeight + 200: btnTop); // randomly generate some numbers, and then simply judge the location information, do not exceed the window display range. El. style. position = 'fixed'; el. style. left = btnLeft + 'px '; el. style. top = btnTop + 'px ';} function over_btn (e) {if (! E) {e = window. event;} btn_move (this, e. clientX, e. clientY);} document. getElementById ('su '). onmouseover = over_btn; // from the source file, Baidu click the button id is su. Use it to get the button and set the reaction of moving the cursor to the button.

All right, this spoof Is About Baidu extensions. You can get the complete code from here. Https://

The extended installation method is the same as described in the previous article. You can see here


Chrome extension and application development (PS: I really appreciate the personality of this author. Not only do I share books, but I also donate all my donations to one fund. Buy electronic address:
Chrome cannot download extended applications. What should I do if I keep displaying them?

You can download and save the extension to your local computer in the cheetah browser store and drag it to chrome to install it.

You need Baidu to find out how to save the. crx plug-in method, which is not complicated. It is just a replacement of a small piece of code.

It's hard to write code here. Du Niang won't let it be published. You can use Baidu

Google chrome versions and extensions

Modify the hosts to enter the app store!
Baidu has a tutorial and cannot add links. You can search for them by yourself!

Hope to help you!

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: 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.