Skip to content

Instantly share code, notes, and snippets.

@marcustyphoon
Last active August 8, 2023 11:02
Show Gist options
  • Save marcustyphoon/dd83e8b5662e9ea7866779d0b5ad04e7 to your computer and use it in GitHub Desktop.
Save marcustyphoon/dd83e8b5662e9ea7866779d0b5ad04e7 to your computer and use it in GitHub Desktop.
(async () => {
/* globals tumblr */
let allBlogs = [];
let resource = '/v2/user/following';
while (resource) {
await Promise.all([
tumblr.apiFetch(resource).then(({ response: { blogs, links } }) => {
console.log(
'collected blogs:',
blogs.map(({ name }) => name),
);
allBlogs.push(...blogs);
resource = links?.next?.href;
}),
new Promise((resolve) => setTimeout(resolve, 500)),
]);
}
allBlogs.sort((a, b) => b.updated - a.updated);
console.log('allBlogs', allBlogs);
const MAX_BLOGS = 50;
let url = `https://www.tumblr.com/timeline/blogpack?blogs=`;
const excludedBlogNames = [];
allBlogs.forEach(({ name }, i) => {
if (i >= MAX_BLOGS) {
excludedBlogNames.push(name);
} else {
url += `${name},`;
}
});
url = url.replace(/,$/, '');
console.log(url);
console.log('excludedBlogNames', excludedBlogNames);
// window.location.href = url;
})();
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
©2023 marcustyphoon and aprilsylph
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment