Write a chrome plugin---a Youku auto plus fan assistant

Source: Internet
Author: User

The main thing about writing a chrome plugin is to write JS, we want to construct the interface (HTML), the style (CSS), and the JSAPI that Chrome gives us, mainly the Chrome API. , debugging can be directly debugged using Chrome's developer Tool (F12) ;

API address first over, this is very important:

If you have never written a chrome plugin, we can refer to this open, there are a lot of ready-made demo, we can directly online to see some simple demo code:

I wrote this Youku auto-subscription assistant using Bootstrap and JQ (personally considered as standard, ('? ') ), also used the sugar cake artdialog plug-in, thanks to the sugar cake great God, the main interface is as follows:

  

If you click the Login Subscription button will refresh the verification code , this verification code in Youku acquired, while jumping out of a prompt pop-up window requires you to enter a verification code, and then click Confirm to automatically subscribe to the users in the subscription list;

In the Setup interface , you can set the automatic login user and password , the user name and password are separated by "---" (cross bar), each user information is separated by "," (comma):

If you want to bulk subscription is very useful, then the problem is, if you have a number of accounts, the 400 accounts at the same time to subscribe (concern) 400 accounts, then what do you do? Automatically enter the verification code tool just fine. Wow, @me;

The process of the Youku login is to get the verification code through get , then send the verification code , username, password ,jsoncallback, to an address via Ajax, If the login succeeds, the successful code is returned, and the cookie is set to the client;

The subscription is via get a link, the parameter is the subscription number that you want to subscribe;

Chrome plug-ins need a configuration file, the name of this file is called "Manifest.json", (grunt use also need a configuration JSON, the same is the same), the file is a variety of configuration parameters, These configuration information is used when you package extensions in Chrome:

 { "name": "Yknono" ,  "version": " 0.0.0 " "manifest_version": 2,  "  Description ":" Youku Login Assistant " "browser_action" : {
Configure the logo image that the app displays in Chrome "Default_icon": "Yk_nono.png" " Default_title ":" Youku_login ",
//Can be opened by clicking on the applied button " Default_popup ":" popup.html "},
//Can be opened by visiting the history of Chrome, "Chrome_url_overrides" {" historical ":" P opup.html "",
//request cross-domain requests, request the Save and read of cookies in the plugin; "Permissions" : [ "http://*/" " cookies " pre>

There is also a main interface of the HTML, called "popup.html", the current structure is as follows :

Then open chrome://extensions/in Chrome and click Package Extender :

There is another dialog box, we click the " Extender root " Browse to the new plug-in directory, the first time you do not need a " private key File ", because Chrome will help you to generate a key file, and then directly select the key file, After all, " optional " is written in the back .... :

Then click "Package Extender", will generate a crx suffix file, if there is a problem chrome will tell you where the error, you find the corresponding problem to change;

You can then drag the CRX file to the "chrome://extensions/" tab and Chrome will prompt you to install it;

CRX.CRX Direct plug-in address: Http://files.cnblogs.com/files/diligenceday/crx.rar

GitHub Address: Https://github.com/sqqihao/youku_auto_sub

API Reference: API Reference for Chrome browser

  

NONO
Source: http://www.cnblogs.com/huyong/
QQ: 287101329

Write a chrome plugin---a Youku auto plus fan assistant

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.