• 请不要在回答技术问题时复制粘贴 AI 生成的内容
liKeYunKeji
V2EX  ›  程序员

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

  •  
  •   liKeYunKeji · Apr 23, 2022 · 5874 views
    This topic created in 1669 days ago, the information mentioned may be changed or developed.
    // ==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

    23 replies  •  2022-05-09 19:01:31 +08:00
    linglin0924
    linglin0924
    Apr 23, 2022
    1
    用上了,不错,感谢楼主
    reorx
    reorx
    Apr 23, 2022 via iPhone
    2
    InstantClick 大法好
    listenfree
    listenfree
    Apr 23, 2022
    3
    建议加上 v2ex.com 的域名 match ,目前只是 www.v2ex.com
    sudoy
    sudoy
    Apr 23, 2022
    4
    原来油猴脚本通过 require 就可以引入第三方 js 库,get 了新技能了,之前一直都是通过 js 注入到 header 去
    Dotennin
    Dotennin
    Apr 23, 2022
    5
    学到了, InstantClick 懒人大法好
    461da73c
    461da73c
    Apr 23, 2022
    6
    Edge 好像不工作。
    这行报错:
    /* globals jQuery, $, InstantClick,waitForKeyElements */
    justin2018
    justin2018
    Apr 23, 2022
    7
    bootcdn.net 这个最好换一下 他家的 CDN 挂过几次 o(╯□╰)o
    Geraltt
    Geraltt
    Apr 23, 2022
    8
    很好用,感谢~
    bo233
    bo233
    Apr 23, 2022 via iPhone
    9
    用上了,感谢
    ijrou
    ijrou
    Apr 23, 2022
    10
    用上了。。。
    SunBK201
    SunBK201
    Apr 23, 2022
    11
    搜索貌似失效了
    shalk
    shalk
    Apr 23, 2022
    12
    还想匹配 v2ex.com/* 怎么改
    goophy
    goophy
    Apr 23, 2022
    13
    切换 夜间模式 就不行了
    learningman
    learningman
    Apr 23, 2022
    14
    @SunBK201 确实,搜索被 gank 了
    fpure
    fpure
    Apr 23, 2022
    15
    InstantClick 有点意思,学到了
    hertzry
    hertzry
    Apr 23, 2022 via Android
    16
    问一下有没有适用于所有网站的无刷新加载插件。
    512357301
    512357301
    Apr 23, 2022 via Android
    17
    @shalk 把 www 改成*试试
    不行的话,再写一行匹配规则
    magicdawn
    magicdawn
    Apr 23, 2022
    18
    @match https://*.v2ex.com/*
    rioshikelong121
    rioshikelong121
    Apr 23, 2022
    19
    Cool.
    unco020511
    unco020511
    Apr 24, 2022
    20
    用上了,感谢
    Bronya
    Bronya
    Apr 24, 2022
    21
    用上了,挺好使,感谢~
    coldmonkeybit
    coldmonkeybit
    Apr 24, 2022
    22
    不错不错赞一个
    songjinxin
    songjinxin
    May 9, 2022
    23
    不错不错 ! 感谢楼主分享!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4333 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 65ms · UTC 08:13 · PVG 16:13 · LAX 00:13 · JFK 03:13
    ♥ Do have faith in what you're doing.