Forked from ailispaw/patch.fix.tumblr.getTumblelogs.tbrl.js
Last active
September 9, 2015 21:16
-
-
Save mactkg/d19a5421c55fa40f5799 to your computer and use it in GitHub Desktop.
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 2015.04" | |
// , "description" : "Fix Tumblr.getTumblelogs 2015.04" | |
// , "include" : ["background"] | |
// , "version" : "0.1.2" | |
// , "downloadURL" : "https://gist.github.com/mactkg/d19a5421c55fa40f5799/raw/ca2da60df200603d322cc7fcafb76eda1febc37f/patch.fix.tumblr.getTumblelogs.tbrl.js" | |
// } | |
// ==/Taberareloo== | |
(function() { | |
addAround(Tumblr, 'getTumblelogs', function (proceed, args, target, methodName) { | |
var self = target; | |
console.log('hi'); | |
return request(Tumblr.LINK + 'settings', { responseType: 'document' }).then(function (res) { | |
var doc = res.response; | |
debugger; | |
if ($X('id("account_actions_login_and_register")', doc)[0]) { | |
throw new Error(chrome.i18n.getMessage('error_notLoggedin', self.name)); | |
} | |
Tumblr.form_key = $X('//input[@name="form_key"]/@value', doc)[0]; | |
Tumblr.channel_id = doc.querySelector('.is_primary .hide_overflow').textContent.trim(); | |
Tumblr.blogs = [Tumblr.channel_id]; | |
return Array.prototype.slice.call(doc.querySelectorAll( | |
'.controls_section .is_tumblelog ' + | |
'a[href^="/settings/blog/"]:not([href="/settings/blog/' + Tumblr.channel_id + '"])' | |
)).reverse().map(function (a) { | |
var id = a.querySelector('.hide_overflow').textContent.trim(); | |
var name = a.querySelector('.small_text').textContent.trim(); | |
Tumblr.blogs.push(id); | |
return { | |
id : id, | |
name: name | |
}; | |
}); | |
}); | |
}); | |
setTimeout(function() { | |
Models.getMultiTumblelogs(); | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
これだと自分が管理してるのしか取得できない