Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix Tumblr.getTumblelogs 2020.04
// ==Taberareloo==
// {
// "name" : "Fix Tumblr.getTumblelogs 2020.04"
// , "description" : "Fix Tumblr.getTumblelogs 2020.04"
// , "include" : ["background"]
// , "version" : "0.5.0"
// , "downloadURL" : "https://gist.githubusercontent.com/ailispaw/3aef8857c274e22f2b41/raw/patch.fix.tumblr.getTumblelogs.tbrl.js"
// }
// ==/Taberareloo==
(function() {
addAround(Tumblr, 'getTumblelogs', function (proceed, args, target, methodName) {
var self = target;
return request(Tumblr.LINK + 'dashboard').then(function (res) {
var html = res.responseText;
if (/{"isLoggedIn":false}/.test(html)) {
throw new Error(chrome.i18n.getMessage('error_notLoggedin', self.name));
}
self.STATE = JSON.parse(html.match(/window\['___INITIAL_STATE___'\] ?= ?(.*?);\n/)[1]);
console.log(self.STATE);
return request(self.LINK + 'settings/account', {responseType : 'document'}).then(function (res) {
self.form_key = $X('//meta[@id="tumblr_form_key"]/@content', res.response)[0];
return request(Tumblr.LINK + 'api/v2/user/info', {
responseType : 'json',
queryString : {
fields : 'name,title,url'
},
headers : {
Authorization : 'Bearer ' + self.STATE.apiFetchStore.API_TOKEN
}
}).then(function (res) {
var json = res.response;
self.USER = json.response.user;
console.log(self.USER);
return self.USER.blogs.filter(function (blog) {
if (blog.primary) {
self.channel_id = blog.name;
self.blogs = [self.channel_id];
}
return !blog.primary
}).reverse().map(function (blog) {
Tumblr.blogs.push(blog.name);
return {
id : blog.name,
name : blog.title
};
});
});
});
});
});
setTimeout(function() {
Models.getMultiTumblelogs();
}, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.