WebExtension: Block request after response header received in Firefox and Chrome Extension

Well. Firefox finally admitted that Chrome’s extension system is better than it’s XUL or Add-on SDK.

So from Firefox 45+, it started to support WebExtension. And now, it even does not allow any extension that is not built with WebExtension API.

This is a good news, because if you want your extension run on both Chrome and Firefox. you won’t need to build twice.

However, even Firefox is trying to support all of the WebExtension API. There are still some differences between Chrome and Firefox.

Recently I got this one.

I was trying to block some requests with the WebRequest API after response header just received. In Chrome, you can easily do it with an onHeadersReceived listener. like this:

    function (details) {
        return {cancel: block};

    {urls: ["URL PATTERN"], types: ["TYPES"]},

But in Firefox, this is not gonna work. Because in Firefox, you can not block a request after the response headers received, you can only redirect it. So you need to to this:

    function (details) {
        return {cancel: block, redirectUrl: "://"};

    {urls: ["URL PATTERN"], types: ["TYPES"]},

with the redirectUrl: “://”, you will redirect it to a local address, and means block it.

How to fix “[Error] ScriptError: Document DocumetID is missing (perhaps it was deleted?)” in Google Script

I’ve created a Google Script APP to help someone export Gmail data to Google SpreadSheet.

It works well when I was testing. But after I publish it as web app, and other users got an error which says

[Error] ScriptError: Document DOCUMENT_ID is missing (perhaps it was deleted?).

And no authorize permission form popups up.  I did not get any useful answer in Google.

After several tests I found I made a stupid mistake.

When publishing the Google Script as web app or other types of APP. There are several options need to take carefully.

Execute the app as:

should set as “User accessing the web app“. (The default value is  Me(myself email)).

With this option, when user first use your app, the authorize permission form will popup and ask user to allow your app access their Google APP.

And no more Document is missing error.

Also don’t forget to chose Anyone in the Who has access to the app option.




How to debug Chrome extension Native Messaging app


Here is how to debug native messageing: enable logging.

By adding a flag, it can open Chrome logging window when starting Chrome.

For Windows, you just need to right click on the Chrome icon in your installation folder / shortcut / taskbar —— Properties  —— add this line behind the target string:

[code]–enable-logging –v=1[/code]

A logging window will start with the Chrome. There the native messaging stuff will be print out.


现在都用SSL了。 这段时间一直在折腾启用这个网站的SSL,前后试过Let’s encrypt 和StartSSL两个服务,均出现各种问题,配置过程也比较繁琐。耗费掉数十个小时不说,也有些备受打击。

而且StartSSL据称被著名流氓公司奇虎360收购了。对于Let’s encrypt,Chrome和iOS似乎对个人签署的证书也不友好,经常显示不信任。






然后点击申请证书, 选择左侧的免费证书即可(也可在右侧购买收费证书) Read More

This Site Enabled SSL

Today I finally got some time to work on my own site.

This small blog used to on a small VPS.

I moved it to Vultr because I heard it is a powerful VPS and it’s price is fair too.

I also enabled SSL, using Free SSL certificate supplier Tencent Cloud service. It’s good, easy to config and doesn’t need to verify again in 1 years.

Got A+ 🙂

iPhone 6S 自动关机问题可能比苹果想象的要严重

在中消协发出查询函以后,苹果对iPhone 6S 近期大量出现的自动关机问题给出的回复是, 电池相关的某个部件在组装前由于长时间暴露在受控环境空气中的时间过长。导致装有这批电池的6S会出现在较寒冷温度下自动关机的问题。

苹果定义的是“一小批”在2015年9月和10月出产的手机会有这样的问题, 并提供了查询网页让消费者查询自己的手机是否在这“一小批”中。符合此条件的手机将可以免费更换电池,若此前已经付费更换电池的用户,则可以报销费用。


而根据我加的几个相关QQ群内的反应,很多并非2015年9月、10月生产的iPhone也有相应的问题,型号从5到6 PLUS都有。而在其他社交媒体上抱怨自己手机这一问题的也很多,遍布全球。因此有理由相信,这并非苹果说的一小批。





KickAssTorrent is down… for a stupid mistake

The world’s biggest torrent sharing website KickAssTorrent was shutdown at 22/7/2016.

This is what happens:

  • An undercover agent of FBI contacted the owner of kickass for advertisement, got his email ID
  • The Owner then purchased something with same email ID in Apple’s store
  • Got exposed. The police arrested him in Poland
  • KickAssTorrent website was shutdown

He hided so many years for running this website, how comes he use the same email to purchase in Apple store and contact with others?

So stupid.

Firefox: How to install and use addon that is not from AMO

In former version, users can install Firefox addon easily by drag and drop the addon file (.xpi file)  into Firefox to install and use it.

But now, user can not do this by default. User can only install addon from AMO (https://addon.mozilla.org). If you download an addon from other website or like me develop addon self. when you drag and drop the file into Firefox. it will be disabled and can not be enable. It says : ADDON NAME could not be verified for use in Firefox and has been disabled.  like this(I’m using Nightly Firefox):

Unnamed QQ Screenshot20151104000045

well, it’s easy to pass this by these steps.

1: Navigate to about:config in Firefox (input about:config into Firefox’s address bar and hit Enter)

2: You might see a warning screen warning the action is not safe. Just hit the blue button  I’ll be careful, I promise .

3:You will see a long list. Input the keywords xpinstall  in the search bar.

4: Find the xpinstall.signatures.required, it’s value should be true now. click this line, change the value to false.


5: You are done, you will see that your addon enabled and working:)