Fix Tumblr.getTumblelogs 2021.10
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.getTumblelogs 2021.12" | |
// , "description" : "Fix Tumblr.getTumblelogs 2021.12" | |
// , "include" : ["background"] | |
// , "version" : "0.5.2" | |
// , "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)); | |
} | |
var validJSON = html.match(/window\['___INITIAL_STATE___'\] ?= ?(.*?);\n/)[1]; | |
validJSON = validJSON.replace(/:undefined,/g, ':null,'); | |
validJSON = validJSON.replace(/:undefined]/g, ':null]'); | |
validJSON = validJSON.replace(/:undefined}/g, ':null}'); | |
self.STATE = JSON.parse(validJSON); | |
console.log(self.STATE); | |
return request(self.LINK + 'settings/account', {responseType : 'document'}).then(function (res) { | |
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