-H::Go
by
noromanba
2018-04-10 [2018/04/10 02:47:04]
Hatena Go URL redirector remover
-
/*
* @title -H::Go
* @description Hatena Go URL redirector remover
* @include *://a.hatena.ne.jp/*
* @license MIT License https://opensource.org/licenses/MIT
* @javascript_url
*/
// e.g.
// http://a.hatena.ne.jp/hatenacinnamon/
// http://a.hatena.ne.jp/hatenagroup/
(() => {
'use strict';
const detox = (ctx) => {
ctx.querySelectorAll([
'a[href^="http://a.st-hatena.com/go?"]'
]).forEach(link => {
// Hatena Go(?) access checker/analyzer(?) syntax;
// http://a.st-hatena.com/go?<ORIGINAL_URL><LEAST_RECENTRY_UPDATED_DATETIME>
// Original URL and Timpestamp is not seperated, 1971-01-01 23:59:59 e.g.
// http://a.st-hatena.com/go?https://exmaple.com/index.html19710101235959
// http://a.st-hatena.com/go?https://exmaple.com/pathname/19710101235959
// http://a.st-hatena.com/go?https://exmaple.com/44444444419710101235959
// WTH
const direct = new URL(link.href).search.slice(1);
// avoid smart `New URL().* ...` code, too hard to minimum
link.href = direct.slice(0, -'yyyyMMddHHmmss'.length);
});
};
detox(document.body);
new MutationObserver(records => {
// TBD omit loop
records.forEach(record => {
const node = record.target;
if (!node.querySelectorAll) return;
detox(node);
});
}).observe(document.body, { childList: true, subtree: true });
})();
-
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。