Created
August 28, 2008 03:00
-
-
Save taizooo/7648 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name play on tumblr | |
// @namespace tag:mattn.jp@gmail.com,2008-04-03:/coderepos.org | |
// @description play current image or vide on tumblr dashboard with 'ENTER' key. if won't work, pray on tumblr! | |
// @include http://www.tumblr.com/dashboard* | |
// @include http://www.tumblr.com/show/* | |
// ==/UserScript== | |
if (typeof window.Minibuffer != 'undefined') with (window.Minibuffer) { | |
var click = function(n) { | |
var e = document.createEvent('MouseEvents'); | |
e.initMouseEvent("click",true,true,unsafeWindow,1,10,50,10,50,0,0,0,0,1,n); | |
n.dispatchEvent(e); | |
}; | |
addShortcutkey({ | |
key: "RET", | |
// key: "h", | |
description: 'tumblr.play', | |
command: function() { | |
try { execute( 'tumblr.play', execute('current-node')); } catch (e) { } | |
}}); | |
addShortcutkey({ | |
key: "h", | |
// key: "i", | |
description: 'tumblr.reblogcount', | |
command: function() { | |
try { execute( 'tumblr.reblogcount', execute('current-node')); } catch (e) { } | |
}}); | |
addCommand({ | |
name: 'tumblr.play', | |
command: function(stdin) { | |
try { | |
if (!stdin.length) stdin = execute('current-node'); | |
var img = $X('./div[starts-with(@id, "highres_photo")]', stdin[0]); | |
for (var n = 0; n < img.length; n++) { | |
if (img[n].style.display != 'none') { | |
click($X('./a', img[n])[0]); | |
return stdin; | |
} | |
else{ | |
click($X('./preceding-sibling::a[1]', img[n])[0]); | |
return stdin; | |
} | |
} | |
var mov = $X('.//div[contains(@id,"watch_") and .//a]', stdin[0]); | |
for (var n = 0; n < mov.length; n++) { | |
if (mov[n].style.display != 'none') { | |
click($X('.//a', mov[n])[0]); | |
return stdin; | |
} | |
} | |
} catch (e) { } | |
return stdin; | |
}}); | |
addCommand({ | |
name: 'tumblr.reblogcount', | |
command: function(stdin) { | |
try { | |
if (!stdin.length) stdin = execute('current-node'); | |
var count = $X('.//a[contains(concat(" ",@class," "), " reblog_count ")]', stdin[0]); | |
for (var n = 0; n < count.length; n++) { | |
click(count[n]); | |
return stdin; | |
} | |
} catch (e) { } | |
return stdin; | |
}}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment