The annual spring festival in China, this year's online ticket booking 12306.cn) has a lot of stories, and online ticket booking is inseparable from browsers. Mainstream browsers include IE, Chrome, Firefox, Safari, sogou, and aoyou, currently, it mainly includes the WebKit kernel and the Trident kernel of IE, as well as a large number of domestic dual-core browsers.
As a strategic battle for the "ENTRANCE" of the Internet, browsers have always been an important weight for giants to win the future, and will also greatly affect users' use, in this Spring Festival, all the browser plug-ins of the ticket were pure WebKit kernel Google Chrome plug-ins, which gave the general public a close-up experience of the power of Chrome. From this perspective, IE was defeated again, although 12306 of websites only support Internet Explorer, a large number of Internet Explorer users found that they had no tickets at the beginning, and they were all stolen by Webkit.
The following is a ticket booking plug-in I use. This plug-in is still available, but the Ministry of Railways has interviewed the plug-ins of various browsers. I cannot introduce it more here, the following describes how to popularize chrome's crx plug-in.
Extension Suffix of Chrome extension files). crx, Google Chrome can automatically associate files with the extension. crx. As a matter of fact, we can find that the crx file contains at least two files, one with the extension. js script file. The other is the file named manifest. some json files may also contain a css file, image file, and HTML webpage file. js script file and manifest. json is an indispensable part.
A Chrome extension is compressed by HTML, CSS, JavaScript, images, and other files. Extension is actually a web page. You can use any browser to provide web page interfaces, from XMLHttpRequest to JSON, and then to the HTML local cache. Each extension consists of the following files:
- A manifest file (main file, in json format)
- At least one HTML file (the topic can have no HTML file)
- JavaScript file (optional, not required)
- Any other files (than slice) you need)
When developing an extension, you need to put these files in a folder. When you release the extension, all the files in this folder will be packaged into a special suffix. crx ZIP file. The following is the plug-in content of the 12306 Ticket Booking Assistant. Change the crx to zip or rar, and decompress it with 7-zip.
Open chrome: // settings/extensions, click "load developing extension" in the top, and select the whole folder you just decompressed and do not select the subfolders) click OK and the installation is successful! After the installation is successful, do not delete the decompressed folder on your computer or change the folder location. Otherwise, it is equivalent to uninstalling the folder ......)
The main file is named manifest. json to describe the extension, including the extension name, version, called file, available domain, and other information. Next let's take a look at what is in the manifest. json file. Open the manifest. json file in notepad and you will find that the file contains the following information:
This extension can call 12306.cn content
If your plug-in needs to interact with a webpage, it needs a Content script, which is often written in JavaScript and called after the webpage is loaded. Content scripts can be viewed as part of a webpage rather than an extension.
The content script can access the page browsed by the current browser and change the display mode of the page (the oil monkey script is the content script ). In the image below, content scripts can read and change the DOM of the webpage. The content script of this plug-in is 12306_ticket_helper.user. In this script, you can do a lot of things that the ticket grabbing software has to do. You can also complete the script on this basis. Therefore, if you are engaged in technology, I will be able to break through the blocking of the Ministry of Railways and get the ticket to go home happily.