Last active
November 10, 2020 10:47
-
-
Save pacochi/a60006551f2cd9351a3439331d7d129b to your computer and use it in GitHub Desktop.
ADVENTAR の表示をアドベントカレンダーっぽくします。
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
// ==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