在访问stackoverflow网站时过于缓慢,虽然已经用了一年多,但每次访问都要等个好几分钟。最近实在是忍不了了,就搜索解决方法。以前还以为是stackoverflow网站被墙了,没想到还是因为引用了google的js文件所以访问过慢。好了知道问题了就进行操作了。
访问https://tampermonkey.net/这个网站下载一个插件
这个的地址是google的所以没用!!! 访问这个地址下载(微云):https://share.weiyun.com/5nFalgR
下载完成之后提示是否安装该拓展程序
google浏览器的话需要在拓展程序里面打开开发者模式才有提示
添加完成之后在浏览器右上角有个小眼睛的图标这个就是刚刚安装的拓展程序
接下来就是写脚本替换原有的google jquery引用了
点击拓展程序 添加新的脚本
将这段代码放入
// ==UserScript==// @name ????????GoogleJsReplace// @namespace ???https://stackoverflow.com/// @version ?????0.1// @description ?try to take over the world!// @author ??????You// @match ???????https://stackoverflow.com/// @grant ???????none// ==/UserScript==(function() { ???‘use strict‘; ???function createScriptElement(file) { ???????var jsElm = document.createElement("script"); ???????jsElm.src = file; ???????return jsElm; ???} ???function replaceGoogleScripts(){ ???????var scripts = document.querySelectorAll(‘script‘); ???????scripts.forEach(function (script) { ???????????var matches = script.src.match(/jquery\/([\d\.]+)\/jquery.min.js/); ???????????if (matches) { ???????????????var version = matches[1]; ???????????????var newSrc = ‘https://cdn.bootcss.com/jquery/‘ + version + ‘/jquery.min.js‘; ???????????????console.log(script); ???????????????script.parentNode.replaceChild(createScriptElement(newSrc), script); ???????????????console.log(‘replaced google jquery with ‘ + newSrc); ???????????} ???????}); ???} ???replaceGoogleScripts();})();
现在修改设置 加载位置修改为document-start 用户匹配修改为:https://stackoverflow.com/
然后保存
上面步骤详解:https://segmentfault.com/a/1190000015588174
现在访问https://stackoverflow.com/网站发现还是很慢 查看html发现google的js引用已经没有了
但发现在访问时还是加载了 这个js
现在修改hosts文件
地址在:C:\Windows\System32\drivers\etc
将google的DNS地址映射到本地
现在访问 https://stackoverflow.com/ 由于将google的jsIP地址映射到本地了 所有找不到就直接404 不会等待了
关于stackoverflow网站访问过慢的问题
原文地址:https://www.cnblogs.com/qs315/p/9480482.html