submit_like(post_id,unlike)
- http://www.tumblr.com//javascript/application.js?112
- http://jsunpack.jeek.org/dec/go?url=www.tumblr.com__javascript_application.js_112
jsunpack 初めてつかった。なんかすごいな。コレ。
function submit_like(post_id,unlike){ if(unlike){ Element.hide('unlike_form_'+post_id); Element.show('like_form_'+post_id) }else{ Element.hide('like_form_'+post_id); Element.show('unlike_form_'+post_id) } new Ajax.Request( $((unlike?'unlike_form_':'like_form_')+post_id).action, { asynchronous:true, parameters:Form.serialize( $(unlike?('unlike_form_'+post_id):('like_form_'+post_id)) ), onFailure:function(){ alert('Sorry, we seem to be having technical trouble. Please try again later.')} } ) }
<form style="" id="like_form_93343718" onsubmit="submit_like(93343718, false); return false;" method="post" action="/like/Jc2s8uJW"> <input type="hidden" value="93343718" name="id"/> <input type="hidden" value="/dashboard" name="redirect_to"/> <input type="hidden" value="kIBqP6v4QIh9LdhbnAMVrvoKo" name="form_key" id="form_key"/> <input type="image" alt="Like" title="Like" class="like_button" src="http://assets.tumblr.com/images/like.png"/> </form>
この location.href な感じを書き換えたいわけだ。
// ==UserScript== // @name love on tumblr // @namespace http://www.tumblr.com/ // @description love current post on tumblr dsbd with 'Shift + l'key. if won't work, pray on tumblr! // @include http://www.tumblr.com/dashboard* // @include http://www.tumblr.com/show/* // @version 0.0.1 // ==/UserScript== if(!window.Minibuffer) return; var $X = window.Minibuffer.$X; //var submit_like = function(id,t){ unsefeWindow.submit_like(id,t); }; window.Minibuffer.addCommand({ name: 'tumblr.Like', command: function(stdin){ stdin.forEach(function(obj){ if (obj.className.match(/not_mine/)){ var id = obj.id.match(/post([\d]+)/)[1]; $X('.//form[starts-with(@id, "unlike_form_")]', obj).forEach(function(e){ var t = (e.style.display != 'none').toString(); location.href = 'javascript:submit_like(' + id + ',' + t + ');' // submit_like(id, t); }); } }); return stdin; }, }); window.Minibuffer.addShortcutkey({ key: 'L', description: 'tumblr.Like', command: function(){ var stdin = []; try{ stdin = window.Minibuffer.execute('pinned-or-current-node'); } catch (e){} window.Minibuffer.execute('tumblr.Like', stdin); window.Minibuffer.execute('clear-pin'); } });