Skip to content

Instantly share code, notes, and snippets.

@stu43005
Created September 21, 2020 12:50
Show Gist options
  • Save stu43005/996c656acbe107bb2e33b9f5937b00ac to your computer and use it in GitHub Desktop.
Save stu43005/996c656acbe107bb2e33b9f5937b00ac to your computer and use it in GitHub Desktop.
查E-H MyTags各tag最後發表日期距今幾天
(async () => {
const gts = Array.from(document.querySelectorAll('.gt').values());
const tags = gts.map(el => el.title).filter(tag => tag.startsWith('artist:') || tag.startsWith('group:'));
for (const tag of tags) {
const res = await fetch(`/tag/${tag}`);
const text = await res.text();
const parser = new DOMParser();
const doc = parser.parseFromString(text, "text/html");
const div = doc.querySelector('.gl1t:nth-child(1) .gl5t div:nth-child(1) div:nth-child(2)');
if (!div) break;
const time = div.innerText;
const days = Math.floor((Date.now() - new Date(time).getTime()) / 8640000) / 10;
const gt = gts.find(el => el.title.includes(tag));
if (!gt) break;
gt.parentNode.appendChild(document.createTextNode(days));
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment