Skip to content

Instantly share code, notes, and snippets.

@pacochi
Last active November 10, 2020 10:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pacochi/a60006551f2cd9351a3439331d7d129b to your computer and use it in GitHub Desktop.
Save pacochi/a60006551f2cd9351a3439331d7d129b to your computer and use it in GitHub Desktop.
ADVENTAR の表示をアドベントカレンダーっぽくします。
// ==UserScript==
// @name [adventar] more adventic
// @namespace hen.acho.co
// @version 0.201110
// @description shuffle cells
// @author pacochi
// @match https://adventar.org/calendars/*
// @downloadURL https://gist.github.com/pacochi/a60006551f2cd9351a3439331d7d129b/raw/adventer_more_adventic.user.js
// @run-at document-idle
// @grant none
// ==/UserScript==
// なんか戻されるからちょっと待ってからシャッフルする
setTimeout((() => {
document.head.appendChild(Object.assign(document.createElement('style'), { textContent: `
.ma-blank { margin: 46px auto 20px auto; text-align: center; font-size: 50px; }
.CalendarTable thead { display: none; }
` }));
const pads = ['🎅', '🛷', '🦌', '⛪', '🌟', '🧦', '🎁', '🎄', '⛄', '🔔'];
const cells = document.querySelectorAll('.CalendarTable td');
cells.forEach(node => node.firstChild.nodeType == 1 || node.replaceChild(Object.assign(
document.createElement('div'), { textContent: pads.shift(), className: 'ma-blank' }
), node.firstChild));
for (let i = cells.length - 1; i--; ) {
const r = Math.trunc(Math.random() * (i + 1));
cells[i].appendChild(cells[r].replaceChild(cells[i].firstChild, cells[r].firstChild));
[cells[i].className, cells[r].className] = [cells[r].className, cells[i].className];
}
}), 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment