Giter Site home page Giter Site logo

krasnayaploshchad / gooreplacer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jiacai2050/gooreplacer.xpi

0.0 2.0 0.0 1.43 MB

一个用于替换网页中Google Fonts/API/themes等的Firefox插件,让你快速打开引用这些资源的页面 :-)

Home Page: http://liujiacai.net/gooreplacer/

Shell 0.71% CSS 6.24% JavaScript 81.05% HTML 12.00%

gooreplacer's Introduction

A replacer for google fonts/api/themes.... to load page faster!

一个用于替换网页中Google Fonts,API,themes等的Firefox插件,让你快速打开这些页面!

安装

  1. Mozilla ADD-ONS下载并安装
  2. 在 Firefox 地址栏中输入about:addons,打开插件控制面板(0.7及以后版本可直接点击工具栏图标进行设置)
  3. 找到 gooreplacer 插件,点击配置
  4. 选中“开启重定向”

 enable-redirect

测试

安装本插件并选中“开启重定向”后,在地址栏中输入下面的链接:

  1. https://fonts.googleapis.com/css?family=Open+Sans
  2. https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js
  3. http://fonts.googleapis.com/css?family=Open+Sans
  4. http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js
  5. http://platform.twitter.com/widgets.js
  6. https://platform.twitter.com/widgets.js

如果能转到lug.ustc.edu.cnraw.githubusercontent.com相应的资源即说明重定向成功。

自定义规则说明

在自定义规则时,支持两种类型:

  • 通配符类型,在 gooreplacer 内部用kind: wildcard标示
  • 正则式类型,在 gooreplacer 内部用kind: regexp标示

在设置在线规则时会用到内部表示。下面举几个例子:

通配符类型

在通配符类型中,原始URL中可以使用*进行?模糊匹配,如果需要表示字符自身的含义,可以使用\进行转义。例如:

www.baidu.com/s\?wd=java   ----通配符--->  www.baidu.com/s?wd=lisp

此外,可以使用^$表示字符的开始与结尾。例如:

baidu.com/$  ----通配符--->  baidu.com/?

这样就能够把baidu.com/重定向到baidu.com/?了,据说,这样能防止劫持吆 -:)

正则式类型

在正则式类型中,原始URL中可以使用JS中的正则表达式语法定义,目的URL中如果要反引用原始URL中的分组,需要使用$1、$2、$3......。例如:

(weibo|ucloud)\.com  ----正则式--->  $1.cn

这样就把weibo.comucloud.com分别重定向到weibo.cnucloud.cn了。

开发环境

Firefox 的附加组件(add-on)与 Chrome 的相比开发难度大些,文档、测试等方面 Chrome 均完胜 Firefox。这也难怪,Firefox 毕竟是有历史包袱的。

这里介绍下开发 gooreplacer 时的环境,希望对想开发 Firefox 附加组件的同学有所帮助。

MDN介绍了三种开发方式,我这里用的是官方推荐的Add-on SDK方式。最初我开发 gooreplacer 用的是基于 python 的cfx,现在官方推荐使用基于 nodejs 的 jpm,现在我已经迁移至jpmjpm的安装比较简单,一行命令搞定

npm install jpm --global

我在开发 gooreplacer 常用的命令也就是jpm runjpm xpi这两个命令。

为了方便测试,使用了Extension Auto-Installer这个附加组件,它能够在命令行里面安装、更新插件,对开发来说很是必要。我封装了个脚本 debug.sh,大家可以参考

如果你在开发时有什么问题,欢迎和我交流,希望和大家一起进步。

注意事项

更新记录

  • 0.1 首次发布
  • 0.1.1 根据Mozilla reviewer的建议,使用tab模块来关闭Observer
  • 0.1.2 当FF中打开并关闭一个tab后,无法跳转链接,原因是关闭Observer的方式不对。现改用windows模块来关闭Observer
  • 0.2 增加官方主页
  • 0.3 修改重定向规则,取消*通配符
  • 0.4 增加用户选项isRedirect,通过Mozilla的官方审查 ----2014.09.21
  • 0.4.5 用户可以通过选择文件自定义规则
  • 0.4.6 增加用户自定义界面
  • 0.4.7 在用户界面,可以禁用某条规则
  • 0.5 用户自定义规则界面测试完毕,发布正式版
  • 0.6 添加导入导出功能,发布正式版
  • 0.7 在工具栏添加gooreplacer图标,发布正式版
  • 0.8 重定向支持正则表达式,支持隐私模式
  • 0.9 重构自定义界面,支持规则编辑功能
  • 1.0 支持在线规则
  • 1.1 bug fix
  • 1.2 Merge Use simple-prefs instead of simple-storage for saving rules,解决重启时失效问题
  • ...
  • 更多功能,等你来开发

License

MIT License © Jiacai Liu

gooreplacer's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.