samtoto

v2ex 的下一主题

  •  
  •   samtoto · Oct 25, 2016 · 37201 views
    This topic created in 3491 days ago, the information mentioned may be changed or developed.

    复制以下代码到 chrome 的 console 。高手勿喷,插件勿喷。

    window.location.href = 'https://www.v2ex.com/t/' + (Number(document.location.href.replace(/https:\/\/www\.v2ex\.com\/t\/(\d?)/i, '$1'))+1)
    
    Supplement 1  ·  Oct 25, 2016

    回复里有大神,学习他们的,所以也可以用

    location.pathname.substring()
    
    19 replies    2016-10-29 10:43:25 +08:00
    yhxx
        1
    yhxx  
       Oct 25, 2016
    Number('$1') 是想做什么
    yhxx
        2
    yhxx  
       Oct 25, 2016
    哦看错了
    还以为是有一个新的“ theme ”
    timor
        3
    timor  
       Oct 25, 2016
    404 错误.
    samtoto
        4
    samtoto  
    OP
       Oct 25, 2016
    @yhxx Number 是 js 里的将 string 转为 数字
    $1 是字符转换的时候的正则表达式里的
    分开写是
    ```javascript
    var urlBase = 'https://www.v2ex.com/t/';
    var urlNow = document.location.href;
    var nextNum = Number(urlNow.replace(/https:\/\/www\.v2ex\.com\/t\/(\d?)/i, '$1')) + 1;
    var url = urlBase + nextNum;
    window.location.href = url
    ```
    samtoto
        5
    samtoto  
    OP
       Oct 25, 2016
    @timor 哦哦 因为没有下一个主题了,你可以找一个老一点的主题比如: https://www.v2ex.com/t/1 在这个页面试试。
    samtoto
        6
    samtoto  
    OP
       Oct 25, 2016
    其实就是想骗点铜币而已,(逃
    ahu
        7
    ahu  
       Oct 25, 2016
    404: Not Found
    dofy
        8
    dofy  
       Oct 25, 2016
    简单点可以直接操作 location.pathname
    samtoto
        9
    samtoto  
    OP
       Oct 25, 2016
    @dofy 确实!不是前端 js 不熟 哈哈哈哈哈哈!
    samtoto
        10
    samtoto  
    OP
       Oct 25, 2016
    @ahu 见 5L
    yhxx
        11
    yhxx  
       Oct 25, 2016
    格式这么固定
    'www.v2ex.com/t/'+ (window.location.href.substring(23,29) * 1 + 1)
    这样就行了吧
    samtoto
        12
    samtoto  
    OP
       Oct 25, 2016
    @yhxx 这个是玉!不错学习了!!!
    imgalaxy
        13
    imgalaxy  
       Oct 25, 2016
    location.pathname="/t/"+(location.href.split(/[/#]/)[4]-(-1))
    imgalaxy
        14
    imgalaxy  
       Oct 25, 2016
    第二个 pathname 换成 href 还能再短 4 个字符
    samtoto
        15
    samtoto  
    OP
       Oct 25, 2016 via iPhone
    @imgalaxy 嗯嗯,受教了
    imgalaxy
        16
    imgalaxy  
       Oct 25, 2016
    location.href=location.href.split(/[/#]/)[4]*1+1
    最终版 不摸鱼了 继续写代码
    tpsxiong
        17
    tpsxiong  
       Oct 26, 2016 via iPhone
    。。为啥不手动改地址栏?
    samtoto
        18
    samtoto  
    OP
       Oct 26, 2016
    @tpsxiong 就是一时兴起 ^_^
    mingyun
        19
    mingyun  
       Oct 29, 2016
    @imgalaxy 厉害了我的哥
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4196 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 121ms · UTC 00:11 · PVG 08:11 · LAX 17:11 · JFK 20:11
    ♥ Do have faith in what you're doing.