Introduction
I'm maintaining at least three repositories about rules for WebExtensions:
https://github.com/ivysrono/HeaderEditorRules
https://github.com/ivysrono/URLRedirectorRules
https://github.com/ivysrono/UpgradeMixedContentBlacklist
I have 680 pull requests for https-everywhere by years.
I would like to record my experience here, to benefit people follow, those who lack resources, especially in the Chinese community. Therefore, this series will mainly be presented in Chinese.
我正在维护至少三个浏览器扩展的规则项目,过去几年里给 https-everywhere 项目提交了 680 条 PR。我想通过乌托邦的平台,将这么多年的经验教训记录下来,以供参考。零基础摸索到现在,深深地感受到,相关中文社区资源匮乏,伸手党太多,独自前行实在痛苦。
The first lesson
关于 https-everywhere 和 mixedcontenthunter 的作用和关系,我之前有过帖子来讲解,参见:
https://steemit.com/cn/@ivysrono/firefox-3-https-everywhere
https://steemit.com/cn/@ivysrono/firefox-5-mixedcontenthunter
几天前我无意中发现了 credit.u51.com 这个网站,然后发现本不应该出现的大量破图,如这个帖子
很容易发现,图片无法正常显示是因为该网站调用了 http://img.credit.u51.com/ 这个不支持 https 的域名来显示图片,而我又用了 mixedcontenthunter 使得图片也被强制 https 了。最简单的解决方案是将这个域名加入到 mixedcontenthunter 的排除规则中,但将图片重定向到主域名来解决似乎是更好的方法。
于是我提交了个规则 https://github.com/EFForg/https-everywhere/pull/14362 ,其中最关键的是下面这条重定向规则:
<rule from="^http://img\.credit\.u51\.com/" to="https://credit.u51.com/" />
<test url="
/>
该规则已经审核通过,等到 https-everywehre 新版发布,credit.u51.com 就可以正确显示了。
几个月没给 EFF 写规则,居然忘了最基本的一条:规则文件是 xml 格式,导致自动测试不通过,非常无语。
Posted on Utopian.io - Rewarding Open Source Contributors