Skip to content

Instantly share code, notes, and snippets.

@kurumigi
Created November 17, 2009 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurumigi/237141 to your computer and use it in GitHub Desktop.
Save kurumigi/237141 to your computer and use it in GitHub Desktop.
[GM Script]Twitter notification auto-click / Twitterの新着通知を自動でクリックします。
// ==UserScript==
// @name Twitter notification auto-click
// @namespace http://d.hatena.ne.jp/kurumigi/
// @description Open "new tweets" automatically.
// @include http://twitter.com/*
// @include https://twitter.com/*
// @version 0.2.1
// ==/UserScript==
(function () {
document.getElementById('page-container').addEventListener('DOMNodeInserted',function(evt) {
if (evt.target.id == 'new-tweets-bar') {
// dispatch 'click' event
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.target.dispatchEvent(ev1);
}, 0);
} else if (/\b(?:stream-item|component)\b/.test(evt.target.className)) {
// dispatch 'AutoPagerize_DOMNodeInserted' event
setTimeout(function(){
var ev2 = document.createEvent('MutationEvent');
ev2.initMutationEvent('AutoPagerize_DOMNodeInserted', true, false, evt.relatedNode, null, '', null, null);
evt.target.dispatchEvent(ev2);
}, 0);
}
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment