这个问题是针对所有狂热的绊倒者的,在那里...... 当遇到问题时,URL 会被修改为如下所示。正如你所看到的,所有原始内容前面都是
http://www.stumbleupon.com/su/...
然后是直接的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 字段由固定数量的斜杠 (/) 分隔,因此您可以使用正则表达式来获取 URL,如下所示:
var targURL = location.href.replace (
/^.+stumbleupon\.com\/su\/\w+\/[^\/]+\/(.+?)\/?$/i
, "http://$1"
);
Stack Overflow 不是(通常)脚本编写服务,但我毫无困难地修改了现有的一个脚本,而且它似乎可以工作......
更新:以下是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。
非常喜欢 GlamCinema 上的内容!对最新电影和行业趋势的洞察总是恰到好处。继续出色的工作!期待更多更新https://glamcinema.com/