Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nikolat/761722 to your computer and use it in GitHub Desktop.
Save nikolat/761722 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hatena Haiku notify auto opener
// @namespace http://www.hatena.ne.jp/Nikola/
// @description はてなハイク1.1の新着通知を自動で開きます。Google Chromeにも対応。
// @include http://h1beta.hatena.ne.jp/*
// @include http://h1beta.hatena.com/*
// ==/UserScript==
(function () {
// via
// http://subtech.g.hatena.ne.jp/secondlife/20091228/1262001989
// http://groups.google.com/group/chromium-extensions-japan/msg/d4828922d4450b3b
var executeBrowserContext = function(funcOrString) {
var s = document.createElement("script");
s.type = "text/javascript";
s.charset = "utf-8";
var t = document.createTextNode("(" + funcOrString.toString() + ")();");
s.appendChild(t);
document.body.appendChild(s);
};
executeBrowserContext(function() {
document.getElementById('main').addEventListener('DOMNodeInserted',function(evt) {
if ((evt.relatedNode.id == 'notifier') && (evt.target.textContent != Hatena.Locale.text('haiku.2010.using_beta'))) {
setTimeout(function(){
var ev1 = document.createEvent('MouseEvent');
ev1.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
evt.relatedNode.dispatchEvent(ev1);
}, 0);
}
}, false);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment