- ?ref=rssを取るGreasemonkeyスクリプト - さそり
http://d.hatena.ne.jp/tzk/20051101/1130823771
の Ref Cutter を自分用に書き換えてみました.
今回,初 greasemonkey いじりです.
ソース見て,こんな感じで書けばいいんでしょ?って感じで
書き換えたので,間違ってたらすみません.
とりあえず,期待通りには動いているようです.
変更点は
- @include の追加
- 正規表現をまとめる
- 正規表現は URL の末尾にマッチするように変更
ないとは思うけど,
http://www.example.com/foo.html?rel=rss&bar=baz
なんて URL が
http://www.example.com/foo.html&foo=bar
にならないように.
- http://www.barks.jp/ 用に Cnet 向けの正規表現を変更.
- http://japan.internet.com/ 用に "?rss" の削除を追加.
変更後のものは以下の通り.
// ==UserScript== // @name Ref Cutter // @namespace http://tzk.net/userscripts // @description Cut '?ref=rss', and so on // @include http://japan.cnet.com/* // @include http://slashdot.jp/* // @include http://japan.linux.com/* // @include http://bb.watch.impress.co.jp/* // @include http://*zdnet.com/* // @include http://www.barks.jp/* // @include http://*impress.co.jp/* // @include http://japan.internet.com/* // ==/UserScript== (function (){ var newUrl = location.href; newUrl = newUrl.replace(/(\?|\&)(ref=|from=)?rss$/ig, ''); //Cnet Japan, barks, etc newUrl = newUrl.replace(/\?topic=[0-9]*/ig, ''); //japan.linux.com if ( newUrl != location.href ) location.href = newUrl; })(); //.user.js
Referrer (Inside):
[2009-11-27-2] Query Cutter - URL の余計なクエリを削除
[2008-08-12-4] 意外と JavaScript もいけるんじゃ……
comments powered by Disqus
[2009-11-27-2] Query Cutter - URL の余計なクエリを削除
[2008-08-12-4] 意外と JavaScript もいけるんじゃ……