GithubHelp home page GithubHelp logo

justjavac / replacegooglecdn Goto Github PK

View Code? Open in Web Editor NEW
3.3K 82.0 514.0 4.05 MB

⚡️ 一个 Chrome 插件:将 Google CDN 替换为国内的。

Home Page: https://chrome.google.com/webstore/detail/replace-google-cdn/kpampjmfiopfpkkepbllemkibefkiice

License: GNU General Public License v3.0

JavaScript 49.86% CSS 3.95% HTML 15.26% Shell 24.59% Python 6.34%
chrome javascript cdn google chrome-extension

replacegooglecdn's Introduction

Replace Google CDN

Chrome Web Store

将 Google CDN 替换为国内的。

缘起

由于众所周知的原因,只需替换一个域名就可以继续使用 Google 提供的前端公共库了。 同样,通过 script 标记引用这些资源,让网站访问速度瞬间提速!

很多网站,尤其是国外网站,为了加快网站的速度,都使用了 Google 的 CDN。 但是在天朝,由于某些原因,导致全球最快的 CDN 变成了全球最慢的。

于是,我写了这个插件/扩展,将 Google 的 CDN 替换成国内的。

原理

借助浏览器提供的API,实现请求地址重定向。

默认未启用的规则, 如需启用请到扩展选项页自行打开

此插件/扩展可以将以下的 CDN 资源替换为国内的:

  1. ajax.googleapis.com - 前端公共库,替换为 ajax.loli.net
  2. fonts.googleapis.com - 免费字体库,替换为 fonts.googleapis.cn
  3. themes.googleusercontent.com - fonts 有时会使用到这个里面的资源,替换为themes.loli.net
  4. fonts.gstatic.com - 免费字体库,替换为 fonts.gstatic.cn
  5. www.google.com/recaptcha - Google 图像验证库,替换为www.recaptcha.net/recaptcha
  6. secure.gravatar.com - gravatar 头像,替换为 gravatar.loli.net
  7. maxcdn.bootstrapcdn.com/bootstrap - bootstrap 框架使用的 CDN,替换为lib.baomitu.com/twitter-bootstrap/
  8. code.jquery.com/jquery-(version)(suffix) - jquery 框架使用的 CDN,替换为https://fastly.jsdelivr.net/npm/jquery@$verson/dist/jquery$suffix
  9. cdnjs.cloudflare.com - 替换为 cdnjs.loli.net 默认未启用, 如需启用请到扩展选项页自行打开
  10. cdn.jsdelivr.net - 替换为 fastly.jsdelivr.net
  11. developers.google.com - 替换为 developers.google.cn 默认未启用, 如需启用请到扩展选项页自行打开
  12. developer.android.com - 替换为 developer.android.google.cn 默认未启用, 如需启用请到扩展选项页自行打开
  13. source.android.com - 替换为 source.android.google.cn 默认未启用, 如需启用请到扩展选项页自行打开
  14. www.gstatic.com - 替换为 www.gstatic.cn 默认未启用, 如需启用请到扩展选项页自行打开
  15. lh3.googleusercontent.com 默认未启用, 如需启用请到扩展选项页自行打开
  16. cdn.sstatic.net- 替换为 sstatic.net 默认未启用,如需启用请到扩展选项页自行打开

扩展选项页使用简述

  1. 双击扩展图标-自动打开扩展选项配置页面
  2. 扩展选项配置页面原理

功能变更记录

效果

安装扩展/插件后访问 https://stackoverflow.com/questions 页面:

第一行是 jquery.min.js 的原始请求 https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js,被拦截并替换,返回的状态码为 307 Internal Redirect,耗时 26ms。第三行是 jquery.min.js 被替换后的请求,33kB,耗时 95ms。

下表是各种资源的网络请求对比(以替换后的速度为基准 100%):

资源 来源 尺寸(kB) 时间(ms) 速度(B/ms) 百分比
jquery.min.js ajax.googleapis.com 0 26 - -
stub.en.js cdn.sstatic.net 18.0 293 61.4 18%
jquery.min.js ajax.loli.net ⚡️ 33.1 95 348.4 100%
clc.min.js cdn.sstatic.net 4.2 399 10.5 30%
full.en.js cdn.sstatic.net 99.6 534 186.5 54%
gpt.js securepubads.g.doubleclick.net 21.3 85 250.6 72%
analytics.js google-analytics.com 19.6 79 248.1 71%
quant.js secure.quantserve.com 9.1 420 21.7 62%
beacon.js sb.scorecardresearch.com 1.8 73 24.7 71%
integrator.js adservice.google.com 🐌 0.3 87 3.4 1%
markup.js clc.stackoverflow.com 🐌 9.2 252 36.5 10%
osd.js googletagservices.com 28.1 90 312.2 89%
rules-p-c1rF4kxgLUzNc.js rules.quantcount.com 🐌 0.4 96 4.2 1%
keyboard-shortcuts.en.js cdn.sstatic.net 7.3 75 97.3 27.9%

打包命令

构建打包结果位于 dist 目录。

打包 V2 版本

bash release-archive.sh

打包 V3 版本

bash release-archive-v3.sh

安装

在线安装

手动安装:

Chrome 安装方法(Google 被墙了上不去):

  1. 下载 ReplaceGoogleCDN 然后解压, 找到 extension 子目录
  2. 打开 Chrome,输入: chrome://extensions/
  3. 勾选 Developer Mode
  4. 选择 Load unpacked extension... 然后定位到刚才解压的文件夹里面的 extension 目录,确定
  5. 这就安装好了,去掉 Developer Mode 勾选。

扩展下载方式三(来自国内镜像)

克隆源代码以后,步骤如上::point_up_2: :point_up_2: :point_up_2:

  1. ReplaceGoogleCDN gitee 镜像
  2. ReplaceGoogleCDN gitcode 镜像
# 克隆源代码
git clone -b master https://gitee.com/mirrors/replacegooglecdn.git --depth=1 --progress

# 或者
git clone -b master https://gitcode.com/mirrors/justjavac/replacegooglecdn.git --depth=1 --progress

# 更新源代码
git -C replacegooglecdn pull --depth=1 --progress --rebase

扩展下载方式四

已经构建好,可以上传扩展市场的代码。

  1. ReplaceGoogleCDN-v3.zip(release v3 版本)支持 chromium 系列浏览器
  2. ReplaceGoogleCDN-v2.zip(release v2 版本)同时支持 firefox 和 chromium 系列浏览器
  3. ReplaceGoogleCDN.zip(全部源码)

构建原理

# 原理: github: page + action

# 构建脚本
https://github.com/jingjingxyk/jingjingxyk.github.io/blob/main/tools/setup-gh-pages-step-02-chromium-extension.sh

# 源代码打包下载地址
https://www.jingjingxyk.com/chromium-extension/ReplaceGoogleCDN.zip

# 已经构建好扩展包下载地址
https://www.jingjingxyk.com/chromium-extension/ReplaceGoogleCDN-v2.zip
https://www.jingjingxyk.com/chromium-extension/ReplaceGoogleCDN-v3.zip

文档

replacegooglecdn's People

Contributors

andy380743909 avatar coldsauce avatar dependabot[bot] avatar dishuostec avatar endle avatar fjy202 avatar gucong3000 avatar i36lib avatar jingjingxyk avatar justjavac avatar mishi321 avatar netcore-jroger avatar stackinspector avatar wuxianucw avatar yuxuanzuo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

replacegooglecdn's Issues

chrome//extensions 加载后任何无法访问http://localhost:9999/

1.下载最新https://github.com/justjavac/ReplaceGoogleCDN.git仓库文件;
2.chrome浏览器输入:chrome//extensions后进入扩展程序界面;
3.打开开发者模式--》加载已解压的扩展程序--》选择将刚才下载库文件中“chrome”目录加载;
4.chrome扩展程序界面出现“Replace Google CDN 0.3.0”插件;
5.关闭chrome开发者模式;
6.chrome浏览器访问“http://localhost:9999/”提示依旧无法打开。
说明:下载的chrome文件包含“icons”和“js”两个文件夹以及“manifest.json”文件。

请各路大侠指导一下问题出在哪里? 谢谢

清单文件缺失或不可读取

加载已解压的扩展程序的时候,报错了:

未能成功加载扩展程序
错误:清单文件确实或不可读取,无法加载清单。

这个错误要怎么解决?

DOTOs

  • 将360改成中科大

打包crx

打包crx,让我们的一些chormium内核浏览器可以从本地安装

How can I count the number of observations per date by using R ?

I have data of dates and amounts, I have to find out how many observations are there per date.

"Amount" = Date
"500" = 2018-11-01
"400" = 2018-11-01
"465" = 2018-11-01
"873" = 2018-11-02
"983" = 2018-11-02
"73" = 2018-11-03
"3829" = 2018-11-04
"3782" = 2018-11-04

MDN加载也很慢

大佬 用了你的方法 stackoverflow加载是挺快的了, MDN网站 加载还是比较慢 有什么解决办法么 跪求

USTC cdn 不可用

建议更换为极客族cdn:
Google前端库(Google Hosted Libraries)
源地址://ajax.googleapis.com/
替换为://gapis.geekzu.org/ajax/

谷歌字体库(Google Fonts)
源地址://fonts.googleapis.com
替换为://fonts.geekzu.org

字体文件(Google Fonts)
源地址://fonts.gstatic.com/
替换为://gapis.geekzu.org/g-fonts/

字体文件(Google Fonts)
源地址://themes.googleusercontent.com/
替换为://gapis.geekzu.org/g-themes/

这个安全不?

我不是学计算机的,这个安全吗?中科大那边可以看到访问的具体数据吗?

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.