Created
November 27, 2010 02:38
-
-
Save taizooo/717500 to your computer and use it in GitHub Desktop.
via http://coderepos.org/share/browser/lang/javascript/userscripts/playontumblr.user.js?rev=38679 | text post image open : http://gyazo.com/0722c749cb50c704d4e9923bdd6b6fce.png -> http://gyazo.com/e8f082af69a038e0ea58775c2cec7ad5.png
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:[email protected],2008-04-03:/coderepos.org | |
// @description play current image or video on tumblr dashboard with 'ENTER' key. open notes with 'h' key. like it with 'l' key. if won't work, pray on tumblr! | |
// @include http://www.tumblr.com/dashboard* | |
// @include http://www.tumblr.com/show/* | |
// @include http://www.tumblr.com/tumblelog/* | |
// @include http://www.tumblr.com/tagged/* | |
// ==/UserScript== | |
(function() { | |
var boot = function() { | |
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", | |
description: 'tumblr.play', | |
command: function() { | |
try { execute( 'tumblr.play', execute('current-node')); } catch (e) { } | |
}}); | |
addShortcutkey({ | |
key: "h", | |
description: 'tumblr.reblogcount', | |
command: function() { | |
try { execute( 'tumblr.reblogcount', execute('current-node')); } catch (e) { } | |
}}); | |
addShortcutkey({ | |
key: "l", | |
description: 'tumblr.like', | |
command: function() { | |
try { execute( 'tumblr.like', 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; | |
} | |
} | |
var timg = $X('.//img[contains(@src,"tumblr.com/tumblr_")]|.//img[@class="inline_external_image"]', stdin[0]); | |
for (var n = 0; n < timg.length; n++) { | |
click(timg[n]); | |
} | |
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; | |
}}); | |
addCommand({ | |
name: "tumblr.like", | |
command: function(stdin) { | |
try { | |
if (!stdin.length) stdin = execute('current-node'); | |
var count = $X('.//a[contains(concat(" ",@class," "), " like_button ")]', stdin[0]); | |
for (var n = 0; n < count.length; n++) { | |
if(!count[n].clientWidth) continue; | |
click(count[n]); | |
return stdin; | |
} | |
} catch(e) {} | |
return stdin; | |
}}); | |
} | |
} | |
if (window.Minibuffer) { | |
boot(); | |
} else { | |
window.addEventListener('GM_MinibufferLoaded', boot, false); | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment