Last active
August 19, 2017 09:28
-
-
Save keshihoriuchi/183993d8ba41828530f1269b5ea45550 to your computer and use it in GitHub Desktop.
patch.fix.tumblr.getForm.tbrl.js
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
// ==Taberareloo== | |
// { | |
// "name" : "Fix Tumblr.getForm 2017.08" | |
// , "description" : "Fix Tumblr.getForm 2017.08" | |
// , "include" : ["background"] | |
// , "version" : "0.0.1" | |
// , "downloadURL" : "https://gist.githubusercontent.com/keshihoriuchi/183993d8ba41828530f1269b5ea45550/raw/patch.fix.tumblr.getForm.tbrl.js" | |
// } | |
// ==/Taberareloo== | |
(function() { | |
addAround(Tumblr, 'getForm', function (proceed, args) { | |
var form = { | |
form_key: Tumblr.form_key, | |
channel_id: Tumblr.channel_id, | |
context_id: '', | |
context_page: 'dashboard', | |
custom_tweet: '', | |
'post[date]': '', | |
'post[draft_status]': '', | |
'post[publish_on]': '', | |
'post[slug]': '', | |
'is_rich_text[one]': '0', | |
'is_rich_text[three]': '0', | |
'is_rich_text[two]': '0', | |
'post[state]': '0', | |
allow_photo_replies: '', | |
send_to_fbog: TBRL.Config.entry.tumblr2facebook ? 'on' : '', | |
send_to_twitter: TBRL.Config.entry.tumblr2twitter ? 'on' : '' | |
}; | |
if (form.form_key && form.channel_id) { | |
return Promise.resolve(form); | |
} | |
if (TBRL.Config.post.multi_tumblelogs) { | |
return Models.getMultiTumblelogs(true).then(function () { | |
form.form_key = Tumblr.form_key; | |
form.channel_id = Tumblr.channel_id; | |
return form; | |
}); | |
} | |
return request(args[0], { responseType: 'document' }).then(function (res) { | |
var doc = res.response; | |
if ($X('id("logged_out_container")', doc)[0]) { | |
throw new Error(chrome.i18n.getMessage('error_notLoggedin', "getForm")); | |
} | |
form.form_key = Tumblr.form_key = $X('//meta[@id="tumblr_form_key"]/@content', doc)[0]; | |
form.channel_id = Tumblr.channel_id = $X('//input[@name="t"]/@value', doc)[0]; | |
return form; | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考リンク