What you need to know about chrome extension development

The chrome extension can modify the request header through the chrome.webRequest.onBeforeSendHeaders callback. Modifying the request header field will be after the TCP connection is initiated, that is, the URL cannot be changed at this time. This interface can also modify the URL, which will cause a redirection , but it seems that the cookie carried after the redirection will be somewhat abnormal, and there is no detailed follow-up.
Then , naturally, a question will come to mind, how to get the response of the request. For this question, the answer is that, under normal circumstances, the chrome extension cannot obtain the request. Response, see, http://stackoverflow.com/questions/18534771/chrome-extension-how-to-get-http-response-body

so unusual, we need to listen through chrome.devtools.network.onRequestFinished Response message, but this interface can only be used in dev tools. The so-called dev tools means that you need to customize a console panel, which is the row of Elements, Network, Console that comes out after pressing F12. After that, add one yourself, see, http://stackoverflow.com/questions/10393638/chrome-extensions-other-ways-to-read-response-bodies-than-chrome-devtools-netw

write a panel of your own It's not difficult, or the html javascript css set, create your own panel through chrome.devtools.panels.create
The problem is that in general, we put debugging information into console.log, which is a good way to debug general pages, but what if we want to debug a console ourselves, http://codemadesimple.wordpress. com/2012/11/15/debug-chrome-dev-tools-panel/, here provides an idea, write the dev page as an options page, and then use the options page to adjust, but if our dev page is the same as the current page Tightly coupled, for example, if we need to debug the response of the current page, his method does not seem to work in this case
http://stackoverflow.com/questions/11103780/console-log-for-chrome-devtools-api , there are some other discussions here, mainly about overloading the console, but I tried it here, it doesn't seem to be very effective,
so my last solution is to alert
another small tip, for the json format alert, it will hit object, this In fact, there is no use of wool. I also know that it is an object. At this time, you can alert(JSON.stringify(xxx)), and you can expand the json content.
If you want to initiate a cross-domain ajax request in the plug-in, remember to write in the manifest Declare the relevant permissions in .json
For older versions of chrome, such as chrome 31, even if you declare cross-domain permissions, you cannot initiate cross-domain requests in the dev page, you can in the background page
Therefore, it is necessary to save the country through a curve. Use the inter-module communication interface of the chrome extension to package the request to be sent to the place where the request can be initiated to send, and then send it back after receiving the reply. The relevant interfaces are chrome.runtime.sendMessage and chrome. runtime.onMessage.addListener
The callback function of chrome.runtime.onMessage.addListener has a function for replying sendResponse. If you need to use this function asynchronously, remember to return true, this is a pit, and it is not easy to find, the official said Yes, runtime.onMessage: The chrome.runtime.onMessage listener must return true if you want to send a response after the listener returns
Recently, google started to push chrome 35.0.1916.114, starting from this version, chrome no longer allows users to install plugins by themselves
There are policies above and countermeasures, and the countermeasures can be summed up as nothing more than, do not upgrade chrome, publish the plug-in to the store, let users run in developer mode
In addition , there is a big killer, https://support.google.com/chrome /a/answer/
188453 , chrome is no longer a browser, but an operating
system— ————

2014-6-13 11:22:07 update

http://tieba.baidu.com/p/1740161948, here mentions the enterprise custom installation method using ad block plus as an example
http://dev.chromium.org/administrators/policy-list-3#ExtensionInstallForcelist, here is Some installation instructions given by google official
https://developer.chrome.com/extensions/hosting.html, here describes the hosting method of the installation file,
but when I try to install it in this way, I can't install it, read I read the document, mentioned the content type, and set it correctly, but it still doesn't work.
So I tried to deploy the installation file of ad block plus to my own environment. It can be installed, so I started to think that there
was a problem with my crx packaging. I found it here, http://productforums.google.com/forum/#!topic/chrome/ayfF5WaeQqc, the students were unable to install the extension of the response web store, and found a log file called chrome debug from this post
http: //www.chromium.org/for-testers/enable-logging, here is how to open the log
to check from the log, and finally found the reason, it turns out that the extension id is different, in the developer mode, I see an id It is a, but after packaging, the extended id becomes b, which does not match the declaration, so it cannot be installed. Wow, if you don't read the log, the ghost knows that the id will not match.
https://developer.chrome.com/extensions/packaging, here are some precautions when packaging
https://developer.chrome.com/extensions/autoupdate, here are some things about the automatic upgrade of extensions
Older versions Chrome, such as 31, is relatively slow when installed in an enterprise. Generally, it takes 1-3 minutes to initiate a request to pull the installation file. The new version is much faster. Usually, it is pulled as soon as it is started. I don’t know why
chrome The slow installation of 31 plugins is related to the version itself, not to the network environment. There is no way to do this
——————


http://zrj.me/archives/1203

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326596559&siteId=291194637