写了个油猴脚本让 V2EX 拥有 SPA 单页的无刷新类似路由切换页面的 Feel

2022-04-23 11:06:06 +08:00
 pytth
// ==UserScript==
// @name         V2EX 无刷新加载页面
// @version      0.1
// @description  V2EX 无刷新切换页面,跳转页面
// @author       You
// @match        https://www.v2ex.com/*
// @grant        none
// @require      https://cdn.bootcdn.net/ajax/libs/instantclick/3.1.0/instantclick.min.js
/* globals jQuery, $, InstantClick,waitForKeyElements */
// ==/UserScript==

(function() {
    'use strict';
    /* 初始化 InstantClick 插件 */
    InstantClick.init();
    /* 隐藏 InstantClick 插件的加载进度条 */
    var style = document.createElement("style");
    style.type = "text/css";
    var text = document.createTextNode("#instantclick-bar{display:none;}");
    style.appendChild(text);
    var head = document.getElementsByTagName("head")[0];
    head.appendChild(style);
})();

https://greasyfork.org/zh-CN/scripts/420178-v2ex%E6%97%A0%E5%88%B7%E6%96%B0%E5%8A%A0%E8%BD%BD%E9%A1%B5%E9%9D%A2

4225 次点击
所在节点    程序员
23 条回复
linglin0924
2022-04-23 11:11:23 +08:00
用上了,不错,感谢楼主
reorx
2022-04-23 11:40:55 +08:00
InstantClick 大法好
listenfree
2022-04-23 11:50:04 +08:00
建议加上 v2ex.com 的域名 match ,目前只是 www.v2ex.com
sudoy
2022-04-23 13:12:24 +08:00
原来油猴脚本通过 require 就可以引入第三方 js 库,get 了新技能了,之前一直都是通过 js 注入到 header 去
Dotennin
2022-04-23 13:24:38 +08:00
学到了, InstantClick 懒人大法好
461da73c
2022-04-23 13:49:36 +08:00
Edge 好像不工作。
这行报错:
/* globals jQuery, $, InstantClick,waitForKeyElements */
justin2018
2022-04-23 15:11:13 +08:00
bootcdn.net 这个最好换一下 他家的 CDN 挂过几次 o(╯□╰)o
Geraltt
2022-04-23 15:52:05 +08:00
很好用,感谢~
bo233
2022-04-23 16:46:42 +08:00
用上了,感谢
ijrou
2022-04-23 16:49:02 +08:00
用上了。。。
SunBK201
2022-04-23 17:00:47 +08:00
搜索貌似失效了
shalk
2022-04-23 17:35:36 +08:00
还想匹配 v2ex.com/* 怎么改
goophy
2022-04-23 19:07:37 +08:00
切换 夜间模式 就不行了
learningman
2022-04-23 19:19:10 +08:00
@SunBK201 确实,搜索被 gank 了
fpure
2022-04-23 20:55:36 +08:00
InstantClick 有点意思,学到了
hertzry
2022-04-23 21:13:23 +08:00
问一下有没有适用于所有网站的无刷新加载插件。
512357301
2022-04-23 21:15:21 +08:00
@shalk 把 www 改成*试试
不行的话,再写一行匹配规则
magicdawn
2022-04-23 23:02:26 +08:00
@match https://*.v2ex.com/*
rioshikelong121
2022-04-23 23:22:46 +08:00
Cool.
unco020511
2022-04-24 09:13:28 +08:00
用上了,感谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/848726

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX