Created
January 31, 2021 06:52
-
-
Save lyo/418d0661323a278169b3389add950f9a to your computer and use it in GitHub Desktop.
privateReblog
This file contains hidden or 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
| --- 20_Tumblr.js.old Sun Apr 13 07:06:00 2008 | |
| +++ 20_Tumblr.js Tue Apr 15 19:51:52 2008 | |
| @@ -180,6 +180,47 @@ | |
| }); | |
| }, | |
| + //testing | |
| + privateReblog : function(url){ | |
| + return maybeDeferred(Tumblr.getReblogToken(url) || doXHR(url).addCallback(function(res){ | |
| + return Tumblr.getReblogToken(res.responseText.match('iframe src="(.*?)"')[1]); | |
| + })).addCallback(function(token){ | |
| + url = Tumblr.TUMBLR_URL+'reblog/'+token.id+'/'+token.token; | |
| + return doXHR(url); | |
| + }).addCallback(function(res){ | |
| + if(formContents(res.responseText)['post[type]'] != 'regular') | |
| + return res; | |
| + | |
| + // reblog as quote | |
| + return doXHR(url + '/quote'); | |
| + }).addCallback(function(res){ | |
| + var fields = formContents(convertToHTMLDocument(res.responseText)); | |
| + // private post! | |
| + fields['post[is_private]'] = 1; | |
| + Tumblr.trimReblogInfo(fields); | |
| + fields.redirect_to = Tumblr.TUMBLR_URL+'dashboard'; | |
| + delete fields.preview_post; | |
| + | |
| + return doXHR(url, { | |
| + referrer : Tumblr.TUMBLR_URL, | |
| + sendContent : fields, | |
| + }); | |
| + }).addCallback(function(res){ | |
| + switch(res.channel.URI.asciiSpec.replace(/\?.*/,'')){ | |
| + case Tumblr.TUMBLR_URL+'dashboard': | |
| + return; | |
| + case Tumblr.TUMBLR_URL+'login': | |
| + throw 'Not loggedin.'; | |
| + case url: | |
| + if(res.responseText.match(/(exceeded|tomorrow)/)) | |
| + throw "You've exceeded your daily post limit."; | |
| + default: | |
| + error(res); | |
| + throw 'Error posting entry.'; | |
| + } | |
| + }); | |
| + }, | |
| + | |
| post : function(params){ | |
| if(params.type == 'reblog') | |
| return Tumblr.reblog(params.source); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment