如何修改Stumbleupon URL's,并提供到内容页面的直接链接

How do I modify Stumbleupon URL's and provide a direct link to the content page?

本文关键字:链接 修改 何修改 Stumbleupon URL      更新时间:2023-09-26

这个问题是针对所有狂热的蹒跚学步者的。。。当遇到障碍时,URL会被修改为如下所示。如您所见,所有原始内容前面都有CCD_ 1,然后直接URL在后面。

如果我遇到一些有趣的东西,我喜欢通过复制URL并将其粘贴到需要的地方来分享。问题是,当任何人点击它时,它会为他们打开障碍栏,并将他们带到内容中。我宁愿只有直接的联系。

http://www.stumbleupon.com/su/1NKFju/:10yM7NnNO:GEYExz6R/toti.jjsoft.hu/public8/nyar1779/a28.jpg
http://www.stumbleupon.com/su/1uGF9s/:11Sd-1n0R:GEYExz6R/www.popularmechanics.com/technology/how-to/home-theater/4342672/
http://www.stumbleupon.com/su/237YPB/:GdOWpKe.:GEYExz6R/nerdsguidetoreading.com/Nerds_Guide_to_Reading/Science_Fiction.html/
http://www.stumbleupon.com/su/2pkYws/:1f+I-KON5:GEYExz6R/www.wizards.com/dnd/images/wd_maps/FRposterLarge_150.jpg/
http://www.stumbleupon.com/su/1ceVWt/:1fdJgD$uT:GEYExz6R/www.psych.upenn.edu/~andrewbg/images/Bluebell-carpet-480.jpg/
http://www.stumbleupon.com/su/2DdDRI/:GvgBVfdV:M-wRpADk/www.nature.com/news/higgs-triumph-opens-up-field-of-dreams-1.10970/

正如你所看到的,前面的大多数绊倒术语的长度几乎相同。然而,第三个也是最后一个短了1个字符。

我想知道是否可以编写一个用户脚本,每当我跌跌撞撞地进入一个新页面时,去掉绊倒的东西,只留下直接链接。

我想保留绊倒栏,但当我到达我新绊倒的页面时,编辑URL并去掉它,而不是实际重新加载页面。

由于Stumbleupon URL字段由固定数量的斜杠(/)分隔,因此可以使用regex来获取URL,如下所示:

var targURL = location.href.replace (
    /^.+stumbleupon'.com'/su'/'w+'/[^'/]+'/(.+?)'/?$/i
    , "http://$1"
);

堆栈溢出不是(正常情况下)脚本编写服务,但我毫不费力地修改了一个现有脚本,它似乎可以工作。。。

更新:以下是Greasemonkey脚本,因为这是问题最初指定的内容。要在Chrome中使用它,请安装Tampermonkey扩展。

// ==UserScript==
// @name     _Stumbleupon, add direct link to content page
// @include  http://www.stumbleupon.com/su/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant    GM_addStyle
// ==/UserScript==
$("#tb-like").before ( '                                                    '
    <li id      = "gmDirectLinkDisp"                                        '
        class   = "tb-btn tb-hide-visitor"                                  '
        title   = "Click for the direct link to the target page, below."    '
    >                                                                       '
        <button>Direct link</button>                                        '
    </li>                                                                   '
' );
$("#gmDirectLinkDisp button").click ( function () {
    var targURL = location.href.replace (
        /^.+stumbleupon'.com'/su'/'w+'/[^'/]+'/(.+?)'/?$/i
        , "http://$1"
    );
    window.prompt (
        "Press 'Ctrl+C' to copy to the clipboard; "
        + "then press `Enter` to close this dialog."
        , targURL
    );
} );
GM_addStyle ( "                             '
    #gmDirectLinkDisp {                     '
        float:              left;           '
    }                                       '
    #gmDirectLinkDisp button {              '
        padding:            0;              '
        margin-top:         10px;           '
    }                                       '
" );

使用StumbleUpon Firefox扩展,你会被直接绊倒到URL,而不是它的框架版本。地址栏中显示的URL前面不会有StumbleUpon.com/su/xxxx。