Skip to content

Instantly share code, notes, and snippets.

@miya2000
Created August 6, 2008 04:10
Show Gist options
  • Save miya2000/4164 to your computer and use it in GitHub Desktop.
Save miya2000/4164 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name hatebu - rewite id-call.
// @description rewite id-call link from the user page to the user bookmark on the entry page.
// @author miya2000
// @namespace http://d.hatena.ne.jp/miya2000/
// @include http://b.hatena.ne.jp/entry/*
// ==/UserScript==
(function() {
function main(){
var as = document.evaluate('\/\/a[starts-with(@href,"http://b.hatena.ne.jp/")][starts-with(text(),"id:")]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var reg = /id:(.*)/;
for (var i = 0, len = as.snapshotLength; i < len; i++) {
var a = as.snapshotItem(i);
var id = reg.exec(a.text)[1];
var bmLink = document.getElementById('bookmark-user-' + id);
if (bmLink) {
a.setAttribute('href', '#bookmark-user-' + id);
}
}
}
document.addEventListener('DOMContentLoaded', main, false);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment