Advent of Code Mobile View

Try to make AoC days easier to view on mobile.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Advent of Code Mobile View
// @namespace    http://tampermonkey.net/
// @version      0.3.0
// @description  Try to make AoC days easier to view on mobile.
// @license MIT
// @author       myklosbotond
// @match        https://adventofcode.com/*/day/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=adventofcode.com
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle(`
body {
  min-width: min(60em, 100vw);
  max-width: 100vw;
}

@media only screen and (max-width: 600px) {
  header {
    overflow: auto;
  }

  #sidebar {
    float: none;
    border-top: 1px solid white;
    width: 100%;
    margin: 0;
    padding: 10px 0 0;
  }
}

main {
  max-width: 100vw;
}

main article, main p {
  max-width: 100%;
}

span[title] {
  outline: 1px dashed gold;
  outline-offset: 2px;
  line-height: calc(1em + 10px);
}

span[title]::after {
  content: ' (' attr(title) ')';
  font-size: .8em;
}
    `);

    document.head.innerHTML += `<meta name="viewport" content="width=device-width, initial-scale=${1}">`;

    if (window.innerWidth < 600) {
        document.body.appendChild(document.getElementById("sidebar"));
    }
})();