はてなブックマークの下部の記事の見出しリンク先が記事ではなくはてブページになってしまっているのを修正します。
Versão de:
// ==UserScript==
// @name Hatena Bookmark Link Modifier
// @namespace knoa.jp
// @description はてなブックマークの下部の記事の見出しリンク先が記事ではなくはてブページになってしまっているのを修正します。
// @include https://b.hatena.ne.jp/entry/*
// @version 1
// @grant none
// ==/UserScript==
(function(){
const modify = function(){
let links = document.querySelectorAll('[class$="title"] > a[href^="/entry/"]');
Array.from(links).forEach(link => {
link.href = link.href.replace('https://b.hatena.ne.jp/entry/s/', 'https://');
link.href = link.href.replace('https://b.hatena.ne.jp/entry/', 'http://');
});
};
modify();
observe(document.body, function(records){
modify();
});
function observe(element, callback, options = {childList: true, characterData: false, subtree: false, attributes: false, attributeFilter: undefined}){
let observer = new MutationObserver(callback.bind(element));
observer.observe(element, options);
return observer;
}
})();