samtoto

v2ex 的下一主题

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