Shined up real nice.
Greasy Fork is available in English.
AbemaTV に見やすく使いやすい番組表と、気軽に登録できる通知機能を提供します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 |
// ==UserScript== // @name AbemaTV Timetable Viewer // @namespace knoa.jp // @description AbemaTV に見やすく使いやすい番組表と、気軽に登録できる通知機能を提供します。 // @include https://abema.tv/* // @version 0.9.9 // @grant none // ==/UserScript== // console.log('AbemaTV? => hireMe()'); (function(){ const SCRIPTNAME = 'TimetableViewer'; const DEBUG = false;/* [update] 軽微な修正。 [to do] main消失、回避不能なら公式番組表ページでも確認して復帰したいが 次の放送までn秒前で停止? 自動復帰しないことがある? [to research] 文字のにじみ Chrome 境界1pxでチラチラチラチラチラチラ パネルを毎回消さずに残す。背後で準備しておく。 現在時刻に戻るスクロールだけやや遅い マウスホバー判定の1pxギャップを上手になくしたい 0:00時点でまだその日の番組情報が空っぽの枠があることが... [possible] 単独起動で通知自動切り替え時の裏番一覧イベント流用 チャンネル切り替えでチャンネルロゴアニメーション あらかじめ一覧を用意しておいて切り替え時のみ2秒ほど表示させるか スマホUI/アプリ提案?(番組表・通知) Edge: element.animate ポリフィル windowイベントリスナの統一化,(events) */ if(window === top && console.time) console.time(SCRIPTNAME); const UPDATECHANNELS = false;/*デバッグ用*/ const CONFIGS = { /* 番組表パネル */ transparency: {TYPE: 'int', DEFAULT: 25},/*透明度(%)*/ height: {TYPE: 'int', DEFAULT: 50},/*番組表の高さ(%)(文字サイズ連動)*/ span: {TYPE: 'int', DEFAULT: 4},/*番組表の時間幅(時間)*/ replace: {TYPE: 'bool', DEFAULT: 1 },/*アベマ公式の番組表を置き換える*/ /* 通知(abema.tvを開いているときのみ) */ n_before: {TYPE: 'int', DEFAULT: 5},/*番組開始何秒前に通知するか(秒)*/ n_change: {TYPE: 'bool', DEFAULT: 1 },/*自動でチャンネルも切り替える*/ n_overlap: {TYPE: 'bool', DEFAULT: 1 },/* 時間帯が重なっている時は通知のみ*/ n_sync: {TYPE: 'bool', DEFAULT: 1 },/*アベマ公式の通知と共有する*/ /* 表示チャンネル */ c_visibles: {TYPE: 'object', DEFAULT: {}},/*(チャンネル名)*/ }; const PIXELRATIO = window.devicePixelRatio;/*Retina比*/ const MINUTE = 60;/*分(s)*/ const HOUR = 60*MINUTE;/*時間(s)*/ const DAY = 24*HOUR;/*日(s)*/ const JST = 9*HOUR;/*JST時差(s)*/ const JDAYS = ['日', '月', '火', '水', '木', '金', '土'];/*曜日*/ const EDAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];/*曜日(class)*/ const TERM = 7 + 1;/*番組スケジュールの取得期間(日)*/ const TERMLABEL = '1週間';/*TERMのユーザー向け表現*/ const CACHEEXPIRE = DAY*1000;/*番組スケジュールのキャッシュ期間(ms)*/ const BOUNCINGPIXEL = 1;/*バウンシングエフェクト用ピクセル*/ const TIMES = [0,3,6,9,12,15,18,21];/*番組表のスクロール位置(時)*/ const NAMEWIDTH = 7.5;/*番組表のチャンネル名幅(vw)*/ const MAXRESULTS = 100;/*番組取得の最大数*/ const NOTIFICATIONREMAINS = 5;/*番組開始後も通知を残しておく時間(s)*/ const NOTIFICATIONAFTER = DAY;/*番組終了後にアベマを開いても通知する期間(s)*/ const ABEMATIMETABLEDURATION = 500;/*アベマ公式番組表を置き換えた際の遷移アニメーション時間(ms)*/ const STALLEDLIMIT = 5;/*映像が停止してから自動リロードするまでの時間(s)*/ const PANELS = ['timetablePanel', 'configPanel'];/*パネルの表示順*/ /* サイト定義 */ const APIS = { CHANNELS: 'https://api.abema.io/v1/channels',/*全チャンネル取得API*/ SCHEDULE: 'https://api.abema.io/v1/media?dateFrom={dateFrom}&dateTo={dateTo}',/*番組予定取得API*/ RESERVATION: 'https://api.abema.io/v1/viewing/reservations/{type}/{id}',/*番組通知API*/ RESERVATIONS: 'https://api.abema.io/v1/viewing/reservations/slots?limit={limit}',/*番組通知取得API*/ FAVORITE: 'https://api.abema.io/v1/favorites/slots/{id}?userId={userId}',/*マイビデオAPI*/ FAVORITES: 'https://api.abema.io/v1/favorites/slots?limit={limit}',/*マイビデオ取得API*/ SLOT: 'https://api.abema.io/v1/viewing/reservations/slots/{id}',/*通知番組情報取得API*/ }; const THUMBIMG = 'https://hayabusa.io/abema/programs/{displayProgramId}/{name}.q{q}.w{w}.h{h}.x{x}.jpg';/*番組サムネイルパス*/ const NOCONTENTS = [/*コンテンツなし番組タイトル*/ '番組なし',/*存在しないけどNOCONTENTS[0]はスクリプト内で代替用のラベルとして使う*/ /^番組告知$/, /^CM$/, /^$/,/*空欄*/ /^CM 【[^】]+】$/,/*【煽り】付きCM(REPLACE後の文字列にマッチ)*/ ]; const REPLACES = [/*番組タイトル置換*/ [/^(【.+?】)(.*)$/, '$2 $1'],/*【煽り】を最後に回す(間に HAIR SPACE を挟む)*/ [/^(\\.+?\/)(.*)$/, '$2 $1'],/*\煽り/を最後に回す(間に SPACE を挟む)*/ [/^([^/]+一挙)\/(.*)$/, '$2 /$1'],/*...一挙/を最後に回す(間に SPACE を挟む)*/ [/^(イブニング4|ナイトフォール7|デイリーナイト10)\/(.*)$/, '$2 /$1'],/*枠名/を最後に回す(間に SPACE を挟む)*/ [/^(Abemaビデオで大好評配信中!)(.*)$/, '$2 $1'],/*最後に回す(間に SPACE を挟む)*/ [/♯([0-9]+)/g, '#$1'],/*シャープをナンバーに統一*/ [/([^ ])((?:\(|\[|<)?#[0-9]+)/g, '$1 $2'],/*直前にスペースがないナンバリングを補完*/ [/([^ ])(\(|\[|<)/g, '$1 $2'],/*直前にスペースがないカッコ開始を補完*/ ]; const NAMEFRAGS = {/*キャストとスタッフの名前の正規化用*/ NONAMES: new RegExp([ '^(?:-|ー|未定|なし|coming soon)$', /*なし*/ '^(?:【|-|ー).+(?:-|ー|】)$', /*【見出し】*/ '^(?:■|◆|●)', /*■見出し*/ ':.+:', /*コロン複数の複数人ベタテキストは判定不能*/ ].join('|')), SKIPS: new RegExp([ '^(?:[^(:]+|[^:]+\\)[^:]*):',/*最初のコロンまでは役職名(カッコ内は無視)*/ '^【[^】]+】', /*太カッコは区切り*/ '^<[^>]+>', /*山カッコは区切り*/ '\\([^)]+\\)(?:・|、|\\/)?', /*(カッコ)内とそれに続く区切り文字は無視*/ '\\[[^\\]]+\\](?:・|、|\\/)?', /*[カッコ]内とそれに続く区切り文字は無視*/ '\\s*(?:その)?(?:ほか|他)(?:多数)?$', /*ほか*/ '\\s*(?:etc\.?|(?:and|&) more)$', /*ほか*/ ].join('|')), SEPARATORS: new RegExp([ '、', /*名前、名前*/ '\\/', /*名前/名前*/ ].join('|')), }; let retry = 10;/*必要な要素が見つからずあきらめるまでの試行回数*/ let site = { targets: [ function screen(){let loading = $('img[src="/images/misc/feed_loading.gif"]'); return (loading) ? site.use(loading.parentNode.parentNode) : false;}, function channelButton(){let button = $('button[aria-label="放送中の裏番組"]'); return (button) ? site.use(button) : false;}, function channelUpButton(){let button = $('button[aria-label="前のチャンネルに切り替える"]'); return (button) ? site.use(button) : false;}, function channelDownButton(){let button = $('button[aria-label="次のチャンネルに切り替える"]'); return (button) ? site.use(button) : false;}, function channelPane(){let button = $('button[aria-label="放送中の裏番組"]'); return (button) ? site.use(button.parentNode.parentNode.nextElementSibling) : false;}, function closer(){let buttons = $$('[data-selector="screen"] > div > button'); Array.from(buttons).forEach((b) => site.use(b, 'closer')); return (buttons) ? true : false;}, function progressbar(){let progressbar = $('#main [role="progressbar"]'); return (progressbar) ? site.use(progressbar.parentNode) : false;}, ], get: { onairs: function(channelPane){return channelPane.querySelectorAll('a[href^="/now-on-air/"]');}, thumbnail: function(a){return a.querySelector('a > div > div:nth-child(1) > div > div:nth-child(1) > img');}, nowonair: function(a){return a.querySelector('a > div > div:nth-child(2)');}, title: function(slot){return slot.querySelector('div:nth-child(1) > span > span:last-of-type');}, duration: function(slot){return slot.querySelector('div:nth-child(2) > span');}, token: function(){return localStorage.getItem('abm_token');}, userId: function(){return localStorage.getItem('abm_userId');}, closer: function(){ /* チャンネル切り替えごとに変わる */ let buttons = $$('[data-selector="closer"]'); for(let i = 0; buttons[i]; i++){ if(buttons[i].clientWidth) return buttons[i]; } }, abemaTimetableButton: function(){ let a = $('header a[href="/timetable"]'); return (a) ? site.use(a, 'abemaTimetableButton') : null; }, abemaTimetableSlotButton: function(channelId, programId){ /* アベマの仕様に依存しまくり */ let index = Array.from($$('div > a[href^="/timetable/channels/"]')).findIndex((a) => a.href.endsWith('/' + channelId)); if(index === -1) return log(`Not found: "${channelId}" anchor.`); let buttons = $$(`div:nth-child(${index + 1}) > div > article > button`);/*index該当チャンネルに絞って効率化*/ if(buttons.length === 0) return log(`Not found: "${channelId}" buttons.`); if(DAY/2 < MinuteStamp.past()) buttons = Array.from(buttons).reverse();/*正午を過ぎていたら逆順に探す*/ for(let i = 0, button; button = buttons[i]; i++){ let div = button.parentNode.parentNode; if(Object.keys(div).some((key) => key.includes('reactInternalInstance') && (div[key].key === programId))) return button; } return log(`Not found: "${programId}" button.`); }, abemaTimetableNowOnAirLink: function(channelId){ let a = $(`a[href="/now-on-air/${channelId}"]`); return (a) ? a : log(`Not found: "${channelId}" link.`); }, abemaNotifyButton: function(target){ switch(true){ case(target.classList.contains('notify')): return false; /* textContentでしか判定できない */ case(target.textContent === 'この番組の通知を受け取る'):/*放送視聴中のボタン*/ case(target.textContent === '通知を受け取る'): case(target.textContent === '今回のみ通知を受け取る'): case(target.textContent === '毎回通知を受け取る'): case(target.textContent === '解除する'):/*マイビデオの可能性もあるが仕方ない*/ return true; default: return false; } }, abemaMyVideoButton: function(target){ switch(true){ case(target.classList.contains('myvideo')): return false; /* 番組表の埋め込みボタンのあやうい判定 */ case(target.attributes['role'] && target.attributes['role'].value === 'checkbox'): /* textContentでしか判定できない */ case(target.textContent === 'マイビデオに追加'): case(target.textContent === '解除する'):/*通知の可能性もあるが仕方ない*/ return true; default: return false; } }, subscriptionType: function(){ /* アベマの仕様に依存しまくり */ if(!window.dataLayer) return log('Not found: window.dataLayer'); for(let i = 0; window.dataLayer[i]; i++){ if(window.dataLayer[i].subscriptionType) return window.dataLayer[i].subscriptionType; } }, screenCommentScroller: function(){return html.classList.contains('ScreenCommentScroller')}, apis: { channels: function(){return APIS.CHANNELS}, timetable: function(){ let toDigits = (date) => date.toLocaleDateString('ja-JP', {year: 'numeric', month: '2-digit', day: '2-digit'}).replace(/[^0-9]/g, ''); let from = new Date(), to = new Date(from.getTime() + TERM*DAY*1000); return APIS.SCHEDULE.replace('{dateFrom}', toDigits(from)).replace('{dateTo}', toDigits(to)); }, reservation: function(id, type){ const types = {repeat: 'slotGroups', once: 'slots'}; return APIS.RESERVATION.replace('{type}', types[type]).replace('{id}', id); }, reservations: function(){return APIS.RESERVATIONS.replace('{limit}', MAXRESULTS)}, favorite: function(id){return APIS.FAVORITE.replace('{id}', id).replace('{userId}', site.get.userId())}, favorites: function(){return APIS.FAVORITES.replace('{limit}', MAXRESULTS)}, slot: function(id){return APIS.SLOT.replace('{id}', id)}, }, }, use: function use(target = null, key = use.caller.name){ if(target) target.dataset.selector = key; elements[key] = target; return target; }, /* [live(生), newcomer(新), first(初), last(終), bingeWatching(一挙), recommendation(注目), none(なし)] の順番 */ marks: ['live', 'newcomer', 'first', 'last', 'bingeWatching', 'recommendation', 'none'], }; class Channel{ constructor(channel = {}){ Object.keys(channel).forEach((key) => { switch(key){ case('programs'): return this.programs = channel.programs.map((program) => new Program(program)); default: return this[key] = channel[key]; } }); } fromChannelSlots(channel, slots){ this.id = channel.id; this.name = channel.name.replace(/^Abema/, '').replace(/チャンネル$/, ''); this.fullName = channel.name; this.order = channel.order; this.programs = slots.map((slot) => new Program().fromSlot(slot, {id: this.id, name: this.fullName})); /* 空き時間を埋める */ let now = MinuteStamp.now(), justToday = MinuteStamp.justToday(), createPadding = (id, startAt, endAt) => new Program({ id: id, title: NOCONTENTS[0], noContent: true, channel: {id: this.id, name: this.fullName}, startAt: startAt, endAt: endAt, }); if(now < this.programs[0].startAt) this.programs.unshift(createPadding(channel.id + '-' + now, now, this.programs[0].startAt)); for(let i = 0; this.programs[i]; i++){ if(this.programs[i + 1] && this.programs[i].endAt !== this.programs[i + 1].startAt){ this.programs.splice(i + 1, 0, createPadding(channel.id + '-' + this.programs[i].endAt, this.programs[i].endAt, this.programs[i + 1].startAt)); }else if(!this.programs[i + 1] && this.programs[i].endAt < justToday + (TERM+1)*DAY){ this.programs.push(createPadding(channel.id + '-' + this.programs[i].endAt, this.programs[i].endAt, justToday + (TERM+1)*DAY)); break;/*抜けないと無限ループになる*/ } } return this; } } class Program{ constructor(program = {}){ Object.keys(program).forEach((key) => { this[key] = program[key]; }); } fromSlot(slot, channel){ /* ID */ this.id = slot.id; this.displayProgramId = slot.displayProgramId; this.series = (slot.programs[0].series) ? slot.programs[0].series.id : slot.programs[0].seriesId; //this.sequence = slot.programs[0].episode.sequence;/*次回*/ this.slotGroup = slot.slotGroup;/*{id, lastSlotId, fixed, name}*/ /* 概要 */ /* {live(生), newcomer(新), first(初), last(終), bingeWatching(一挙), recommendation(注目), drm(マークなし)} からマークなしを取り除く */ Object.keys(slot.mark).forEach((key) => { if(core.html.marks[key] === undefined){ delete slot.mark[key]; if(DEBUG && key !== 'drm') log('Unknown mark:', key); } }); this.marks = slot.mark || {}; this.title = Program.modifyTitle(normalize(slot.title)); this.links = slot.links;/*[{title, type(2のみ), value(url)}]*/ //this.highlight = slot.highlight;/*短い*/ this.detailHighlight = slot.detailHighlight/*長い*/ || slot.highlight/*短い*/; this.content = slot.content;/*詳細*/ this.noContent = this.hasNoContent(this.title); this.channel = channel;/*{id, name}*/ /* サムネイル */ this.thumbImg = slot.programs[0].providedInfo.thumbImg; this.sceneThumbImgs = slot.programs[0].providedInfo.sceneThumbImgs || []; /* クレジット */ this.casts = (slot.programs[0].credit.casts || []).map(normalize); this.crews = (slot.programs[0].credit.crews || []).map(normalize); this.copyrights = slot.programs[0].credit.copyrights; /* 時間 */ this.startAt = slot.startAt; this.endAt = slot.endAt; this.timeshiftEndAt = slot.timeshiftEndAt; this.timeshiftFreeEndAt = slot.timeshiftFreeEndAt; /* シェア */ //this.hashtag = slot.hashtag; //this.sharedLink = slot.sharedLink; return this; } static modifyTitle(title){ for(let i = 0, replace; replace = REPLACES[i]; i++){ title = title.replace(replace[0], replace[1]); } return title; } static appendMarks(title, marks){ const latters = ['last'];/*タイトルの後に付くマーク*/ if(marks) Object.keys(marks).forEach((mark) => { if(!core.html.marks[mark]) return;/*htmlが用意されていない*/ if(latters.includes(mark)) return title.parentNode.appendChild(createElement(core.html.marks[mark]())); return title.parentNode.insertBefore(createElement(core.html.marks[mark]()), title); }); } static getRepeatTitle(a, b){ let getCommon = (a, b) => { for(let i = 0, parts = a.split(/(?=\s)/), common = ''; parts[i]; i++){ if(b.includes(parts[i].trim())) common += parts[i]; else if(common) return common;/*共通部分が途切れたら終了*/ } return b;/*共通部分がなければ後続を優先する*/ } return [getCommon(a, b), getCommon(b, a)].sort((a, b) => a.length - b.length)[0].trim(); } static modifyDuration(duration){ return duration.replace(/[0-9]+月[0-9]+日\([月火水木金土日]\)/g, '').replace(/0([0-9]:[0-9]{2})/g, '$1'); } static linkifyNames(node, click){ if(node.textContent.match(NAMEFRAGS.NONAMES) !== null) return; for(let i = 0, n; n = node.childNodes[i]; i++){/*回しながらchildNodesは増えていく*/ if(n.data === '') continue; let pos = n.data.search(NAMEFRAGS.SKIPS); switch(true){ case(pos === -1): if(split(n)) i++;/*セパレータの分を1つ飛ばす*/ append(n); break; case(pos === 0): n.splitText(RegExp.lastMatch.length); break; case(0 < pos): n.splitText(pos);/*nをpos直前で分割*/ if(split(n)) i++;/*セパレータの分を1つ飛ばす*/ append(n); break; } } function split(n){ let pos = n.data.search(NAMEFRAGS.SEPARATORS); if(1 <= pos){ n.splitText(pos); n.nextSibling.splitText(RegExp.lastMatch.length); return true; } } function append(n){ n.data = n.data.trim(); if(n.data === '') return; let span = document.createElement('span'); span.className = 'name'; node.insertBefore(span, n.nextSibling); span.appendChild(n); span.addEventListener('click', click); } } get group(){ return (this.slotGroup) ? this.slotGroup.id : undefined; } get repeat(){ return this.group; } get once(){ return this.id; } get duration(){ return this.endAt - this.startAt; } get dateString(){ let long = {month: 'short', day: 'numeric', weekday: 'short', hour: 'numeric', minute: '2-digit'}, short = {hour: 'numeric', minute: '2-digit'}; let start = new Date(this.startAt*1000), end = new Date(this.endAt*1000); let startString = start.toLocaleString('ja-JP', long); let endString = end.toLocaleString('ja-JP', (start.getDate() === end.getDate()) ? short : long); return `${startString} 〜 ${endString}`; } get justifiedDateString(){ return this.justifiedDateToString(this.startAt) + ' 〜 ' + this.justifiedTimeToString(this.endAt); } get justifiedStartAtShortDateString(){ return this.justifiedShortDateToString(this.startAt); } get startAtString(){ return this.timeToString(this.startAt); } get endAtString(){ return this.timeToString(this.endAt); } get timeString(){ return this.startAtString + ' 〜 ' + this.endAtString; } get timeshiftString(){ let endAt = MyVideo.isPremiumUser() ? this.timeshiftEndAt : this.timeshiftFreeEndAt; if(!endAt) return ''; let remain = endAt - MinuteStamp.justToday(); switch(true){ case(DAY*2 <= remain): return `${Math.floor(remain/DAY)}日後の ${this.dateToString(endAt)} まで見逃し視聴できます`; case(DAY <= remain): return `あす ${this.dateToString(endAt)} の ${this.timeToString(endAt)} まで見逃し視聴できます`; case(0 <= remain): return `きょう ${this.dateToString(endAt)} の ${this.timeToString(endAt)} まで見逃し視聴できます`; default: return ''; } } hasNoContent(title){ return NOCONTENTS.some((frag) => title.match(frag)); } dateToString(timestamp){ return new Date(timestamp * 1000).toLocaleDateString('ja-JP', {month: 'short', day: 'numeric', weekday: 'short'}); } timeToString(timestamp){ return new Date(timestamp * 1000).toLocaleTimeString('ja-JP', {hour: 'numeric', minute: '2-digit'}); } justifiedShortDateToString(timestamp){ /* toLocaleString('ja-JP')の2-digitが効かないバグがあるので */ let date = new Date(timestamp * 1000), d = { date: ('00' + date.getDate()).slice(-2), day: JDAYS[date.getDay()], hours: ('00' + date.getHours()).slice(-2), minutes: ('00' + date.getMinutes()).slice(-2), }; return `${d.date}(${d.day}) ${d.hours}:${d.minutes}`; } justifiedDateToString(timestamp){ /* toLocaleString('ja-JP')の2-digitが効かないバグがあるので */ let date = new Date(timestamp * 1000), d = { month: date.getMonth() + 1, date: ('00' + date.getDate()).slice(-2), day: JDAYS[date.getDay()], hours: ('00' + date.getHours()).slice(-2), minutes: ('00' + date.getMinutes()).slice(-2), }; return `${d.month}月${d.date}日(${d.day}) ${d.hours}:${d.minutes}`; } justifiedTimeToString(timestamp){ let date = new Date(timestamp * 1000), d = { hours: ('00' + date.getHours()).slice(-2), minutes: ('00' + date.getMinutes()).slice(-2), }; return `${d.hours}:${d.minutes}`; } } class Thumbnail{ constructor(displayProgramId, name, size = 'small'){ const x = (window.innerWidth * PIXELRATIO < 960) ? 1 : 2; const sizes = {/*解像度確保のためx2を指定させていただく*/ large: {q: 95, w: 256, h: 144, x: x}, small: {q: 95, w: 135, h: 76, x: x}, }; this.displayProgramId = displayProgramId; this.name = name; this.params = sizes[size]; } get node(){ let img = document.createElement('img'); img.classList.add('loading'); img.addEventListener('load', function(){ img.classList.remove('loading'); }); img.src = THUMBIMG.replace( '{displayProgramId}', this.displayProgramId ).replace( '{name}', this.name ).replace( '{q}', this.params.q ).replace( '{w}', this.params.w ).replace( '{h}', this.params.h ).replace( '{x}', this.params.x ); return img; } } class MinuteStamp{ static now(){ let now = new Date(), minutes = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes()); return minutes.getTime() / 1000; } static past(){ let now = new Date(), minutes = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes()); return ((minutes.getTime() / 1000) + JST) % DAY; } static justToday(){ let now = new Date(), today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); return today.getTime() / 1000; } static timeToString(timestamp){ return new Date(timestamp * 1000).toLocaleTimeString('ja-JP', {hour: 'numeric', minute: '2-digit'}); } static timeToClock(timestamp){ let time = new Date(timestamp * 1000); return createElement(core.html.clock(time.getHours(), ('00' + time.getMinutes()).slice(-2))); } static minimumDateToString(timestamp){ let d = new Date(timestamp * 1000); return `${d.getDate()}${JDAYS[d.getDay()]}`; } } class Button{ static getOnceButtons(id){ return document.querySelectorAll(`button.notify[data-once="${id}"]`); } static getRepeatButtons(id){ return document.querySelectorAll(`button.notify[data-once][data-repeat="${id}"]`); } static getButtonTitle(button){ if(button.classList.contains('active')) return button.dataset.titleActive; if(button.classList.contains('search')) return button.dataset.titleSearch; if(button.classList.contains('repeat')) return button.dataset.titleRepeat; if(button.classList.contains('once')) return button.dataset.titleOnce; return button.dataset.titleDefault; } static addActive(button){ Button.reverse(button, 'add', 'active'); } static removeActive(button){ Button.reverse(button, 'remove', 'active'); } static addOnce(id){ Button.getOnceButtons(id).forEach((b) => Button.reverse(b, 'add', 'once')); Slot.getOnceSlots(id).forEach((s) => Slot.highlight(s, 'add', 'active')); } static removeOnce(id){ Button.getOnceButtons(id).forEach((b) => Button.reverse(b, 'remove', 'once')); Slot.getOnceSlots(id).forEach((s) => {if(!Notifier.match(s.dataset.once)) Slot.highlight(s, 'remove', 'active')}); } static addRepeat(id){ Button.getRepeatButtons(id).forEach((b) => Button.reverse(b, 'add', 'repeat')); Slot.getRepeatSlots(id).forEach((s) => Slot.highlight(s, 'add', 'active')); } static removeRepeat(id){ Button.getRepeatButtons(id).forEach((b) => Button.reverse(b, 'remove', 'repeat')); Slot.getRepeatSlots(id).forEach((s) => {if(!Notifier.match(s.dataset.once)) Slot.highlight(s, 'remove', 'active')}); } static addSearch(id){ Button.getOnceButtons(id).forEach((b) => Button.reverse(b, 'add', 'search')); Slot.getOnceSlots(id).forEach((s) => Slot.highlight(s, 'add', 'active')); } static removeSearch(id){ Button.getOnceButtons(id).forEach((b) => Button.reverse(b, 'remove', 'search')); Slot.getOnceSlots(id).forEach((s) => {if(!Notifier.match(s.dataset.once)) Slot.highlight(s, 'remove', 'active')}); } static reverse(button, action, name){ button.classList.add('reversing'); button.addEventListener('transitionend', function(e){ button.classList[action](name); button.classList.remove('reversing'); button.title = Button.getButtonTitle(button); }, {once: true}); } static shake(button){ button.animate([ {transform: 'translateX(-10%)'}, {transform: 'translateX(+10%)'}, ], { duration: 50, iterations: 5, }); } static pop(button){ button.animate([/*放物線*/ {transform: 'translateY( +7%)'}, {transform: 'translateY( +6%)'}, {transform: 'translateY( +4%)'}, {transform: 'translateY( 0%)'}, {transform: 'translateY(-32%)'}, {transform: 'translateY(-48%)'}, {transform: 'translateY(-56%)'}, {transform: 'translateY(-60%)'}, {transform: 'translateY(-62%)'}, {transform: 'translateY(-63%)'}, {transform: 'translateY(-63%)'}, {transform: 'translateY(-62%)'}, {transform: 'translateY(-60%)'}, {transform: 'translateY(-56%)'}, {transform: 'translateY(-48%)'}, {transform: 'translateY(-32%)'}, {transform: 'translateY( 0%)'}, {transform: 'translateY(-16%)'}, {transform: 'translateY(-24%)'}, {transform: 'translateY(-28%)'}, {transform: 'translateY(-30%)'}, {transform: 'translateY(-31%)'}, {transform: 'translateY(-31%)'}, {transform: 'translateY(-30%)'}, {transform: 'translateY(-28%)'}, {transform: 'translateY(-24%)'}, {transform: 'translateY(-16%)'}, {transform: 'translateY( 0%)'}, {transform: 'translateY( +3%)'}, {transform: 'translateY( +2%)'}, {transform: 'translateY( 0%)'}, ], { duration: 750, }); } } class Slot{ static getOnceSlots(id){ return document.querySelectorAll(`.slot[data-once="${id}"]`); } static getRepeatSlots(id){ return document.querySelectorAll(`.slot[data-repeat="${id}"]`); } static highlight(slot, action, name){ slot.classList.add('transition'); animate(function(){ slot.classList[action](name); slot.addEventListener('transitionend', function(e){ slot.classList.remove('transition'); }, {once: true}); }); } } class Notifier{ static sync(){ if(!configs.n_sync) return; let add = (type, id) => { let updateLocal = (type, program) => { switch(type){ case('once'): notifications['once'][program.once] = Program.modifyTitle(normalize(program.title)); Notifier.updateOnceProgram(program); break; case('repeat'): notifications['repeat'][program.repeat] = Program.modifyTitle(normalize(program.title)); Notifier.updateRepeatPrograms(program); break; } Notifier.save(); }; let program = core.getProgramById(id); if(program) return updateLocal(type, program); /* 臨時チャンネル番組などでprogramが見つからないときはアベマに問い合わせる */ /* (最初からprogramデータ付きで取得するAPIオプション(&withDataSet=true)もあるけど無駄が多いので採用しない) */ let xhr = new XMLHttpRequest(); xhr.open('GET', site.get.apis.slot(id)); xhr.setRequestHeader('Authorization', 'bearer ' + site.get.token()); xhr.responseType = 'json'; xhr.onreadystatechange = function(){ if(xhr.readyState !== 4 || xhr.status !== 200) return; if(!xhr.response.dataSet || !xhr.response.dataSet.slots) return log(`Not found: reservation data ${type} "${id}"`); //log('xhr.response:', xhr.response); let slot = xhr.response.dataSet.slots[0], channel = xhr.response.dataSet.channels[0];/*xhr.responseをそのまま使うとパフォーマンス悪い*/ slot.programs = xhr.response.dataSet.programs; let program = new Program().fromSlot(slot, {id: channel.id, name: channel.name}); updateLocal(type, program); }; xhr.send(); }; /* こっからsync処理 */ let xhr = new XMLHttpRequest(); xhr.open('GET', site.get.apis.reservations()); xhr.setRequestHeader('Authorization', 'bearer ' + site.get.token()); xhr.responseType = 'json'; xhr.onreadystatechange = function(){ if(xhr.readyState !== 4 || xhr.status !== 200) return; if(!xhr.response.slots) return log(`Not found: reservations data`); //log('xhr.response:', xhr.response); let slots = xhr.response.slots;/*xhr.responseをそのまま使うとパフォーマンス悪い*/ /* あちらにしかないものはあちらで能動的に登録したとみなしてこちらにも登録 */ for(let i = 0; slots[i]; i++){ if(!slots[i].repetition && !Notifier.matchOnce(slots[i].slotId)){ if(Notifier.match(slots[i].slotId)) continue;/*こちらでは検索通知として登録済み*/ add('once', slots[i].slotId); }else if(slots[i].repetition && !Notifier.matchRepeat(slots[i].slotGroupId)){ add('repeat', slots[i].slotId); } } /* こちらにしかないものはあちらで能動的に削除したとみなしてこちらでも削除 */ let now = MinuteStamp.now();/*放送終了までは残す*/ Object.keys(notifications.once).forEach((key) => { if(slots.some((slot) => slot.slotId === key)) return;/*1回か毎回かは問わずあちらにもある*/ let program = notifications.programs.find((p) => p.once === key); if(program && (now < program.endAt)) return;/*あちらにないけどまだ放送中*/ delete notifications.once[key]; }); Object.keys(notifications.repeat).forEach((key) => { if(slots.some((slot) => slot.slotGroupId === key)) return;/*あちらにもある*/ let program = notifications.programs.find((p) => p.repeat === key); if(program && (now < program.endAt)) return;/*あちらにないけどまだ放送中*/ delete notifications.repeat[key]; }); notifications.programs = notifications.programs.filter((program) => { if(slots.some((slot) => slot.slotId === program.id)) return true;/*あちらにもある*/ if(Notifier.matchSearch(program)) return true;/*検索通知として登録済み*/ if(now < program.endAt) return true;/*まだ放送中*/ }); Notifier.save(); }; xhr.send(); } static addOnce(program){ if(Notifier.matchOnce(program.once)) return; Notifier.add(program, 'once'); Notifier.updateOnceProgram(program); Notifier.save(); } static removeOnce(program){ Notifier.remove(program, 'once'); notifications.programs = notifications.programs.filter((p) => { if(Notifier.matchOnce(p.once)) return true; if(Notifier.matchRepeat(p.repeat)) return true; if(Notifier.matchSearch(p)) return true; }); Notifier.save(); } static addRepeat(program){ if(Notifier.matchRepeat(program.repeat)) return; Notifier.add(program, 'repeat'); Notifier.updateRepeatPrograms(program); Notifier.save(); } static removeRepeat(program){ Notifier.remove(program, 'repeat'); notifications.programs = notifications.programs.filter((p) => { if(Notifier.matchOnce(p.once)) return true; if(Notifier.matchRepeat(p.repeat)) return true; if(Notifier.matchSearch(p)) return true; }); Notifier.save(); } static updateRepeatTitle(program){ notifications.repeat[program.repeat] = Program.getRepeatTitle(notifications.repeat[program.repeat], program.title); } static add(program, type){ Notification.requestPermission(); notifications[type][program[type]] = program.title; if(configs.n_sync) Notifier.reserve(program[type], type); } static remove(program, type){ delete notifications[type][program[type]]; if(configs.n_sync) Notifier.unreserve(program[type], type); } static addSearch(key, marks){ Notification.requestPermission(); notifications.search[key] = marks; let matchIds = Notifier.updateSearchPrograms(key, marks); Notifier.save(); return matchIds;/*通知ボタンくるりんぱ用*/ } static removeSearch(key, marks){ delete notifications.search[key]; let unmatchIds = []; notifications.programs = notifications.programs.filter((p) => { if(Notifier.matchSearch(p)) return true; unmatchIds.push(p.id);/*今回searchの対象から外れたid*/ if(Notifier.matchRepeat(p.repeat)) return true; if(Notifier.matchOnce(p.once)) return true; if(configs.n_sync) Notifier.unreserve(p.id, 'once');/*公式に検索通知がないので1回通知として削除する*/ }); Notifier.save(); return unmatchIds;/*通知ボタンくるりんぱ用*/ } static reserve(id, type){ notifications.requests = notifications.requests.filter((r) => r.id !== id);/*既に予定済みなら上書きするのでいったん削除*/ notifications.requests.push({action: 'PUT', id: id, type: type}); } static unreserve(id, type){ notifications.requests = notifications.requests.filter((r) => r.id !== id);/*既に予定済みなら上書きするのでいったん削除*/ notifications.requests.push({action: 'DELETE', id: id, type: type}); } static request(){ if(!configs.n_sync || !notifications.requests[0]) return;/*リクエスト予定なし*/ let request = notifications.requests[0], action = request.action, id = request.id, type = request.type;/*1つずつしか処理しない*/ /* APIから通知を予約する */ let xhr = new XMLHttpRequest(); xhr.open(action, site.get.apis.reservation(id, type)); xhr.setRequestHeader('Authorization', 'bearer ' + site.get.token()); if(DEBUG) xhr.onreadystatechange = function(){ if(xhr.readyState !== 4 || xhr.status !== 200) return; log('xhr.response:', xhr.response); }; xhr.send(); /* リクエストキューを削除 */ notifications.requests.shift(); Notifier.save(); } static updateOnceProgram(program){ let now = MinuteStamp.now(); if(program.startAt < now) return;/*放送中・終了した番組は登録しない*/ if(Notifier.match(program.id)) return;/*既に通知予定済み*/ notifications.programs.push(program); notifications.programs.sort((a, b) => a.startAt - b.startAt); } static updateRepeatPrograms(program){ /* channelsに含まれない臨時チャンネルの番組もあるので先に登録を済ませておく */ if(!Notifier.match(program.id)){ notifications.programs.push(program); Notifier.updateRepeatTitle(program); } /* channelsから該当する番組を登録する */ for(let c = 0, now = MinuteStamp.now(); channels[c]; c++){ for(let p = 0, target; target = channels[c].programs[p]; p++){ if(target.startAt < now) continue;/*放送中・終了した番組は登録しない*/ if(!target.repeat || target.repeat !== program.repeat) continue;/*検証対象のidではない*/ if(Notifier.match(target.id)) continue;/*既に通知予定済み*/ notifications.programs.push(target); Notifier.updateRepeatTitle(target); } } notifications.programs.sort((a, b) => a.startAt - b.startAt); } static updateSearchPrograms(key, marks){ let matchIds = [], now = MinuteStamp.now(); for(let c = 0; channels[c]; c++){ for(let p = 0, program; program = channels[c].programs[p]; p++){ if(program.startAt < now) continue;/*放送中・終了した番組は登録しない*/ if(!core.matchProgram(program, key, marks)) continue;/*key,marksに該当しない番組はもちろん登録しない*/ matchIds.push(program.id);/*このkey,marksに該当するid*/ if(Notifier.match(program.id)) continue;/*programsに重複登録はしない(onceやrepeat,または既存searchによって登録済み)*/ notifications.programs.push(program); if(configs.n_sync) Notifier.reserve(program.id, 'once');/*公式に検索通知がないので1回通知として登録する*/ } } notifications.programs.sort((a, b) => a.startAt - b.startAt); return matchIds; } static updateAllPrograms(){ Object.keys(notifications.repeat).forEach((repeat) => Notifier.updateRepeatPrograms(notifications.programs.find((p) => p.repeat === repeat))); Object.keys(notifications.search).forEach((key) => Notifier.updateSearchPrograms(key, notifications.search[key])); Notifier.save(); } static matchOnce(once){ return notifications.once[once]; } static matchRepeat(repeat){ return notifications.repeat[repeat]; } static matchSearch(program){ return Object.keys(notifications.search).find((key) => core.matchProgram(program, key, notifications.search[key])); } static match(id){ if(notifications.programs.some((p) => p.id === id)) return true; } static createPlayButton(program){ let button = createElement(core.html.playButton()); button.classList.add('channel-' + program.channel.id); if(location.href.endsWith('/now-on-air/' + program.channel.id)) button.classList.add('current'); button.addEventListener('click', Notifier.playButtonListener.bind(program)); return button; } static playButtonListener(e){ let program = this, button = e.target/*playButtonListener.bind(program)*/; core.goChannel(program.channel.id); e.stopPropagation(); } static createRepeatAllButton(program){ let button = createElement(core.html.repeatAllButton()); if(Notifier.matchRepeat(program.repeat)){ button.classList.add('active'); button.title = button.dataset.titleActive; }else{ button.title = button.dataset.titleDefault; } button.dataset.repeat = program.repeat; button.addEventListener('click', Notifier.repeatAllButtonListener.bind(program)); return button; } static repeatAllButtonListener(e){ let program = this, button = e.target/*repeatAllButtonListener.bind(program)*/; switch(true){ case(button.classList.contains('active')): Notifier.removeRepeat(program); Button.removeActive(button); Button.removeRepeat(program.repeat); break; default: Notifier.addRepeat(program); Button.addActive(button); Button.addRepeat(program.repeat); break; } } static createNotifyButton(program){ let button = createElement(core.html.notifyButton()); if(Notifier.matchOnce(program.once)) button.classList.add('once'); if(Notifier.matchRepeat(program.repeat)) button.classList.add('repeat'); let key = Notifier.matchSearch(program); if(key){ button.classList.add('search'); button.dataset.key = key; } button.title = Button.getButtonTitle(button); button.dataset.once = program.once; if(program.repeat) button.dataset.repeat = program.repeat; button.addEventListener('click', Notifier.notifyButtonListener.bind(program)); return button; } static notifyButtonListener(e){ let program = this, button = e.target/*notifyButtonListener.bind(program)*/, searchKey = button.dataset.key; let updateSearchPane = () => { if(!elements.searchPane || !elements.searchPane.isConnected) return; if(elements.searchPane.dataset.mode !== 'notifications') return; for(let target = button.parentNode; target; target = target.parentNode){ if(target === elements.searchPane) return;/*searchPaneでのクリック時はなにもしない*/ } core.timetable.searchPane.buildNotificationsHeader(); core.timetable.searchPane.listAllNotifications(); }; switch(true){ case(searchKey !== undefined): if(!elements.timetablePanel.isConnected) core.timetable.createPanel(); core.timetable.searchPane.search(searchKey, notifications.search[searchKey]); Button.shake(button); break; case(Notifier.matchRepeat(program.repeat) !== undefined): Button.shake(button); break; case(Notifier.matchOnce(program.once) !== undefined): Notifier.removeOnce(program); Button.removeOnce(program.once); updateSearchPane(); break; default: Notifier.addOnce(program); Button.addOnce(program.once); updateSearchPane(); break; } e.preventDefault(); e.stopPropagation(); } static createSearchButton(key){ let button = createElement(core.html.notifyButton()); button.classList.add('search'); button.dataset.key = key; button.title = Button.getButtonTitle(button); button.addEventListener('click', Notifier.searchButtonListener); return button; } static searchButtonListener(e){ let button = e.target/*notifyButtonListener.bind(key)*/, searchKey = button.dataset.key; if(!elements.timetablePanel.isConnected) core.timetable.createPanel(); core.timetable.searchPane.search(searchKey, notifications.search[searchKey]); Button.shake(button); e.preventDefault(); e.stopPropagation(); } static createButton(program){ let now = MinuteStamp.now(); if(program.startAt <= now) return Notifier.createPlayButton(program); if(now < program.startAt) return Notifier.createNotifyButton(program); } static createSearchAllButton(key, marks){ let button = createElement(core.html.searchAllButton(key, marks.map((name) => core.html.marks[name]()).join(''))); if(notifications.search[key] && notifications.search[key].join() === marks.join()) button.classList.add('active'); button.addEventListener('click', Notifier.searchAllButtonListener.bind({key: key, marks: marks})); return button; } static searchAllButtonListener(e){ let key = this.key, marks = this.marks, button = e.target/*searchAllButtonListener.bind({key: key, marks: marks})*/; switch(true){ case(notifications.search[key] && notifications.search[key].join() === marks.join()): Notifier.removeSearch(key, marks).forEach((id) => Button.removeSearch(id)); Button.removeActive(button); break; default: Notifier.addSearch(key, marks).forEach((id) => Button.addSearch(id)); Button.addActive(button); break; } core.timetable.searchPane.updateSearchFillters(key, marks); Notifier.save(); } static notify(){ /* notifications.programsを確認して通知を表示する。番組が終了するまでprogramは保持しておく */ let now = Date.now() / 1000, buffer = location.href.includes('/now-on-air/') ? 2 : 0;/*視聴ページでの通知を優先させるための工夫*/ for(let p = 0, programs = notifications.programs; programs[p]; p++){ let program = programs[p], closeMe; if(now < program.startAt - (configs.n_before + buffer)) return;/*まだ通知時刻じゃない(後続のprogramも同様なのでreturn)*/ /* 複数タブで通知させないための工夫 */ let ns = Storage.read('notifications');/*先にprogramを通知していないか確認する*/ switch(true){ case(ns.programs.length !== programs.length):/*ほかで終了番組を削除済み*/ case(ns.programs[p].notification && !program.notification):/*ほかで通知済み*/ notifications = ns; for(let i = 0; notifications.programs[i]; i++) notifications.programs[i] = new Program(notifications.programs[i]); return; } setTimeout(function(){ /* 通知時刻になっている */ if(!program.notification){/*未通知*/ switch(true){ case(!configs.c_visibles[program.channel.id]):/*非表示チャンネル*/ if(program.endAt <= now) programs = programs.filter((p) => p.id !== program.id), p--; break; case(now < program.startAt):/*通知時刻*/ case(now < program.endAt):/*放送中*/ program.notification = new Notification(program.title, { body: `${program.timeString} ${program.channel.name}`, }); closeMe = program.notification.close.bind(program.notification); program.notification.addEventListener('click', function(e){ core.goChannel(program.channel.id); closeMe(); }); if(configs.n_change && (!configs.n_overlap || p === 0)){ window.addEventListener('beforeunload', closeMe);/*通知が開いたままになるのを防ぐ*/ core.goChannel(program.channel.id);/*ページ遷移が発生した場合に即閉じられるのはやむを得ない*/ setTimeout(function(){ window.removeEventListener('beforeunload', closeMe); closeMe(); }, (Math.max(program.startAt - now, 0) + NOTIFICATIONREMAINS)*1000);/*番組開始時刻+REMAINSまで*/ }else{ setTimeout(function(){ closeMe(); }, (Math.max(program.endAt - now, 0))*1000);/*番組終了時刻まで*/ } break; case(program.endAt <= now):/*手遅れ*/ program.notification = new Notification(program.title, { body: `[放送終了] ${program.channel.name}`, }); setTimeout(function(){program.notification.close()}, 2 * NOTIFICATIONREMAINS*1000); break; } }else{/*通知済み*/ if(now < program.endAt) return;/*まだ番組は続いている*/ /* 番組が終了したようなので */ programs = programs.filter((p) => p.id !== program.id), p--; if(programs[0] && programs[0].notification){/*別の通知番組がまだ放送中である*/ if(configs.n_change){ /* 「時間帯が重なっている時は通知のみ」オンなら、優先されるべき最初に開始した番組へ移動 */ if(configs.n_overlap){ core.goChannel(programs[0].channel.id); if(programs[0].notification.close){ setTimeout(function(){programs[0].notification.close()}, NOTIFICATIONREMAINS*1000); } /* 「時間帯が重なっている時は通知のみ」オフなら、優先されるべき最後に開始した番組へ移動 */ }else{ for(let n = 0; programs[n]; n++){ if(programs[n + 1] && programs[n + 1].notification) continue;/*まだ最後じゃない*/ core.goChannel(programs[n].channel.id); if(programs[n].notification.close){ setTimeout(function(){programs[n].notification.close()}, NOTIFICATIONREMAINS*1000); } } } }else{ /* 開いたままの通知があるならその後を託す */ for(let n = 0; programs[n]; n++){ if(!programs[n].notification) break;/*開いたままの通知はひとつもなさそう*/ if(programs[n].notification.close) return;/*開いたままの通知にその後を託す*/ } /* 放送中の通知番組が複数ある */ if(programs[1] && programs[1].notification){ let notification = new Notification(SCRIPTNAME, { body: `通知予約した番組がまだほかにも放送中です`, }); setTimeout(function(){notification.close()}, 2 * NOTIFICATIONREMAINS*1000); if(elements.channelPane.getAttribute('aria-hidden') === 'true') elements.channelButton.click(); /* 放送中の通知番組がひとつだけある */ }else{ programs[0].notification = new Notification(programs[0].title, { body: `${programs[0].timeString} ${programs[0].channel.name}`, }); closeMe = programs[0].notification.close.bind(programs[0].notification); programs[0].notification.addEventListener('click', function(e){ core.goChannel(programs[0].channel.id); closeMe(); }); setTimeout(function(){ closeMe(); }, (Math.max(programs[0].endAt - now, 0))*1000);/*番組終了時刻まで*/ } } } } notifications.programs = programs;/*参照じゃなかったの?という気もするけどこうしないと保存されない*/ Notifier.save(); }, buffer * 1000); } } static updateCount(){ let button = elements.notificationsButton; if(!button) return; if(parseInt(button.dataset.count) === notifications.programs.length) return; button.dataset.count = button.querySelector('.count').textContent = notifications.programs.length; Button.pop(button); } static save(){ Notifier.updateCount(); Storage.save('notifications', notifications); } } class MyVideo{ static sync(){ /* 視聴期限切れもあちらで消えるので自動的に反映される */ let xhr = new XMLHttpRequest(); xhr.open('GET', site.get.apis.favorites()); xhr.setRequestHeader('Authorization', 'bearer ' + site.get.token()); xhr.responseType = 'json'; xhr.onreadystatechange = function(){ if(xhr.readyState !== 4 || xhr.status !== 200) return; if(!xhr.response.slots) return log(`Not found: MyVideo data`); //log('xhr.response:', xhr.response); let slots = xhr.response.dataSet.slots;/*xhr.responseをそのまま使うとパフォーマンス悪い*/ /* あちらにしかないものはあちらで能動的に登録したとみなしてこちらにも登録 */ for(let i = 0; slots[i]; i++){ if(!myvideos.some((p) => p.id === slots[i].id)){ let program = core.getProgramById(slots[i].id); if(program) myvideos.push(program); } } /* こちらにしかないものはあちらで能動的に削除したとみなしてこちらでも削除 */ myvideos = myvideos.filter((myvideo) => (slots.some((slot) => slot.id === myvideo.id))); /* 更新 */ myvideos.sort((a, b) => a.startAt - b.startAt); Storage.save('myvideos', myvideos); }; xhr.send(); } static add(program){ if(MyVideo.match(program.id)) return; myvideos.push(program); myvideos.sort((a, b) => a.startAt - b.startAt); Storage.save('myvideos', myvideos); MyVideo.request('PUT', program.id); } static remove(program){ myvideos = myvideos.filter((p) => (p.id !== program.id)); Storage.save('myvideos', myvideos); MyVideo.request('DELETE', program.id); } static request(action, id){ /* APIから通知を予約する */ let xhr = new XMLHttpRequest(); xhr.open(action, site.get.apis.favorite(id)); xhr.setRequestHeader('Authorization', 'bearer ' + site.get.token()); if(DEBUG) xhr.onreadystatechange = function(){ if(xhr.readyState !== 4 || xhr.status !== 200) return; log('xhr.response:', xhr.response); }; xhr.send(); } static match(id){ if(myvideos.some((p) => p.id === id)) return true; } static createMyvideoButton(program){ let button = createElement(core.html.myvideoButton()); if(MyVideo.match(program.id)){ button.classList.add('active'); button.title = button.dataset.titleActive; }else{ button.title = button.dataset.titleDefault; } button.addEventListener('click', MyVideo.buttonListener.bind(program)); return button; } static buttonListener(e){ let program = this, button = e.target;/*buttonListener.bind(program)*/ switch(true){ case(MyVideo.match(program.id)): MyVideo.remove(program); Button.removeActive(button); break; default: MyVideo.add(program); Button.addActive(button); break; } e.stopPropagation(); } static isPremiumUser(){ return (site.get.subscriptionType() !== 'freeUser'); } } let html, elements = {}, configs = {}; let channels = [], myvideos = [], notifications = { once: {},/*1回通知{id: title}*/ repeat: {},/*毎回通知{id: title}*/ search: {},/*検索通知{key: marks}*/ programs: [],/*通知予定{program}*/ requests: [],/*リクエスト予定{action, id, type}*/ }; let core = { initialize: function(){ /* 一度だけ */ html = document.documentElement; html.classList.add(SCRIPTNAME); core.config.read(); core.read(); core.addStyle(); core.panel.createPanels(); core.listenUserActions(); core.ticktock(); core.abemaTimetable.initialize(); Notifier.updateAllPrograms(); }, ticktock: function(){ let last = new Date(), now = new Date(); setInterval(function(){ last = now, now = new Date(); switch(true){ /* 毎日処理 */ case (now.getDate() !== last.getDate()): core.updateChannels(); core.timetable.buildTimes(); core.timetable.buildDays();/*先に作ったtimesのdisable判定を含む*/ /* 毎時処理 */ case (now.getHours() !== last.getHours()): if(now.getDate() === last.getDate()) core.checkChannels(); Notifier.sync(); MyVideo.sync(); /* 毎分処理 */ case (now.getMinutes() !== last.getMinutes()): core.timetable.shiftTimetable(); /* 毎秒処理 */ default: core.checkUrl(); Notifier.notify(); Notifier.request(); core.checkStalled(); } }, 1000); }, checkUrl: function(){ location.previousUrl = location.previousUrl || ''; if(location.href === location.previousUrl) return;/*URLが変わってない*/ if(location.href.startsWith('https://abema.tv/now-on-air/')){/*テレビ視聴ページ*/ if(location.previousUrl.startsWith('https://abema.tv/now-on-air/')){/*チャンネルを変えただけ*/ elements.closer = site.get.closer(); }else{/*テレビ視聴ページになった*/ core.ready(); } }else if(location.href.startsWith('https://abema.tv/timetable')){/*番組表ページ*/ if(location.previousUrl === '') core.abemaTimetable.openOnAbemaTimetable();/*初回のみ*/ }else{ /*nothing*/ } location.previousUrl = location.href; }, read: function(){ /* ストレージデータの取得とクラスオブジェクト化 */ channels = Storage.read('channels') || channels; for(let i = 0; channels[i]; i++) channels[i] = new Channel(channels[i]); if(!channels.length) core.updateChannels(); else if(DEBUG && UPDATECHANNELS) core.updateChannels(); notifications = Storage.read('notifications') || notifications; for(let i = 0; notifications.programs[i]; i++) notifications.programs[i] = new Program(notifications.programs[i]); myvideos = Storage.read('myvideos') || myvideos; for(let i = 0; myvideos[i]; i++) myvideos[i] = new Program(myvideos[i]); Notifier.sync(); MyVideo.sync(); }, ready: function(){ /* 必要な要素が出揃うまで粘る */ for(let i = 0, target; target = site.targets[i]; i++){ if(target() === false){ if(!retry) return log(`Not found: ${target.name}, I give up.`); log(`Not found: ${target.name}, retrying...`); return retry-- && setTimeout(core.ready, 1000); } } elements.closer = site.get.closer(); log("I'm Ready."); core.timetable.createButton(); core.channelPane.observe(); /* clickイベントを統括するScreenCommentScrollerの準備完了を待つ必要がある */ setTimeout(function(){ if(!site.get.screenCommentScroller()) return; /* チャンネル切り替えイベントをいつでも流用するための準備 */ if(elements.channelPane.getAttribute('aria-hidden') === 'false') return;/*既に開かれている*/ /* 裏番組一覧が開かれたら即閉じる準備 */ let observer = observe(elements.channelPane.firstElementChild, function(records){ if(elements.channelPane.getAttribute('aria-hidden') === 'true') return; observer.disconnect();/*一度だけ*/ core.channelPane.modify();/*idなどを付与する*/ elements.closer.click(); setTimeout(function(){html.classList.remove('channelPaneHidden')}, 1000);/*チラ見せさせない*/ }); core.channelPane.openHide(); }, 1000); }, checkChannels: function(){ let xhr = new XMLHttpRequest(); xhr.open('GET', site.get.apis.channels()); xhr.responseType = 'json'; xhr.onreadystatechange = function(){ if(xhr.readyState !== 4 || xhr.status !== 200) return; if(!xhr.response.channels) return log(`Not found: data`); log('xhr.response:', xhr.response); let cs = xhr.response.channels;/*xhr.responseをそのまま使うとパフォーマンス悪い*/ if(!cs.every((c) => channels.some((channel) => channel.id === c.id))) core.updateChannels(); }; xhr.send(); }, updateChannels: function(callback){ let xhr = new XMLHttpRequest(); xhr.open('GET', site.get.apis.timetable()); xhr.setRequestHeader('Authorization', 'bearer ' + site.get.token()); xhr.responseType = 'json'; xhr.onreadystatechange = function(){ if(xhr.readyState !== 4 || xhr.status !== 200) return; if(!xhr.response.channels || !xhr.response.channelSchedules) return log(`Not found: data`); log('xhr.response:', xhr.response); let ss = xhr.response.channelSchedules, cs = xhr.response.channels, slots = {};/*xhr.responseをそのまま使うとパフォーマンス悪い*/ /* configs.c_visibles更新 */ if(Object.keys(configs.c_visibles).length === 0){ for(let i = 0, c; c = cs[i]; i++) configs.c_visibles[c.id] = 1; }else{ for(let i = 0, c; c = cs[i]; i++){ if(configs.c_visibles[c.id] === undefined) configs.c_visibles[c.id] = 1;/*新規チャンネル*/ } Object.keys(configs.c_visibles).forEach((key) => { if(configs.c_visibles[key] === 0) return;/*非表示にした情報は残す*/ if(!cs.some((c) => c.id === key)) delete configs.c_visibles[key];/*非表示でなければ将来復活しても表示されるだけなので廃止チャンネルとみなしてかまわない*/ }); } Storage.save('configs', configs); /* channels更新 */ channels = [];/* いったんクリア */ for(let i = 0, s; s = ss[i]; i++){ slots[s.channelId] = (slots[s.channelId]) ? slots[s.channelId].concat(s.slots) : s.slots; } for(let i = 0, c; c = cs[i]; i++){ channels[i] = new Channel().fromChannelSlots(c, slots[c.id]); } /* 反映 */ Storage.save('channels', channels, MinuteStamp.justToday()*1000 + CACHEEXPIRE);/*1週間分で3MBくらいあるのでキャッシュする*/ core.addStyle();/*チャンネル数によってフォントサイズを変えるので*/ core.timetable.rebuildTimetable(); Notifier.updateAllPrograms(); if(callback) callback(); }; xhr.send(); }, goChannel: function(id){ if(location.href.endsWith('/now-on-air/' + id)) return;/*すでに目的のチャンネルにいる*/ switch(true){ /* 番組視聴ページにいる */ case(elements.channelPane && elements.channelPane.isConnected): /* 裏番組一覧から正規のチャンネル切り替えイベントを流用する */ let a = elements.channelPane.querySelector(`a[data-channel="${id}"]`); if(a === null) return location.assign('/now-on-air/' + id); a.click(); core.updateCurrentChannel(id); return true; /* 置き換えた公式番組表ページにいる */ case(configs.replace && location.href.endsWith('/timetable')): core.abemaTimetable.goChannel(id); return true; default: return location.assign('/now-on-air/' + id); } }, skipChannel: function(direction = +1){ if(!location.href.includes('/now-on-air/')) return; let loop = (i) => { switch(true){ case(direction === +1): if(i === channels.length - 1) return 0; else return i + 1; case(direction === -1): if(i === 0) return channels.length - 1; else return i - 1; } }; for(let c = 0; channels[c]; c++){ if(!location.href.endsWith('/now-on-air/' + channels[c].id)) continue; for(let i = loop(c), target; target = channels[i]; i = loop(i)){ if(configs.c_visibles[target.id]){ if(i === loop(c)){ core.updateCurrentChannel(target.id); return false;/*スキップ不要*/ }else{ core.goChannel(target.id); return true;/*スキップした*/ } } if(target === channels[c]) return false;/*一周してしまった*/ } } }, updateCurrentChannel(id){ /* playButtonのcurrentを付け替える */ $$('button.play.current').forEach((b) => b.classList.remove('current')); $$('button.play.channel-' + id).forEach((b) => b.classList.add('current')); /* channelPaneのcurrentを付け替える */ if(elements.channelPane){ let previous = elements.channelPane.querySelector('a[data-current="true"]'); if(previous) delete previous.dataset.current; let current = elements.channelPane.querySelector(`a[data-channel="${id}"]`); if(current) current.dataset.current = 'true';/*classは公式にclassNameで上書きされてしまうので*/ core.channelPane.scroll(current); } /* channelsUlのcurrentを付け替える */ if(elements.channelsUl){ let previous = elements.channelsUl.querySelector('.channel.current'); if(previous) previous.classList.remove('current'); let current = elements.channelsUl.querySelector('.channel#channel-' + id); if(current) current.classList.add('current'); } }, listenUserActions: function(){ window.addEventListener('click', function(e){ switch(true){ /* チャンネル切り替えボタン */ case(e.target === elements.channelUpButton): case(e.target === elements.channelDownButton): if(core.skipChannel((e.target === elements.channelDownButton) ? +1 : -1)){ e.stopPropagation(); e.preventDefault(); } /*skip不要ならデフォルトのチャンネル切り替えに任せる*/ return; /* アベマ公式の通知・マイビデオボタンが押されたら同期する */ case(e.isTrusted && configs.n_sync && site.get.abemaNotifyButton(e.target)): return setTimeout(Notifier.sync, 1000); case(e.isTrusted && site.get.abemaMyVideoButton(e.target)): return setTimeout(MyVideo.sync, 1000); } }, true); window.addEventListener('keydown', function(e){ if(!location.href.includes('/now-on-air/')) return; switch(true){ /* テキスト入力中は反応しない */ case(['input', 'textarea'].includes(document.activeElement.localName)): return; /* Alt/Shift/Ctrl/Metaキーが押されていたら反応しない */ case(e.altKey || e.shiftKey || e.ctrlKey || e.metaKey): return; /* 上下キーによるチャンネル切り替え */ case(e.key === 'ArrowUp'): case(e.key === 'ArrowDown'): document.activeElement.blur();/*上下キーによるスクロールを防止*/ if(core.skipChannel((e.key === 'ArrowDown') ? +1 : -1)){ e.stopPropagation(); e.preventDefault(); } /*skip不要ならデフォルトのチャンネル切り替えに任せる*/ return; } }, true); let resize = function(){ core.channelPane.modify(); core.timetable.fitWidth(); }; window.addEventListener('resize', function(e){ if(!window.resizing) resize(); clearTimeout(window.resizing), window.resizing = setTimeout(function(){ resize(); window.resizing = null; }, 500); }); }, checkStalled: function(){ if(document.hidden || !location.href.includes('/now-on-air/')) return; /* 連続で再読込した時はもう少し粘る */ let limit = Storage.read('stalledlimit') || STALLEDLIMIT, expire = Date.now() + 1000*60; /* main消失バグに対応 */ let main = $('#main'); if(!main) return; if(main.children.length === 0){ if(!main.loadedOnce) return;/*ページ読み込み直後は猶予する*/ main.vanishedCount = (main.vanishedCount || 0) + 1; log('Vanished?', main.vanishedCount); if(limit <= main.vanishedCount){ Storage.save('stalledlimit', limit + 1, expire); return location.reload(); } }else{ if(!main.loadedOnce) main.loadedOnce = true; if(1 <= main.vanishedCount){ main.vanishedCount--; log('Recovering vanished?', main.vanishedCount); } } /* 映像または音声の停止を検知する */ let videos = $$('video[src]'), audios = $$('audio[src]'), progress = 0.5/*1秒の間に最低限進んでいなければならない秒数*/; if(!videos.length) return; switch(true){ case(Array.from(videos).every((v) => v.paused)): case(audios.length && Array.from(audios).every((a) => a.paused)): case(Array.from(videos).some((v) => !v.paused && (v.currentTime - v.previousTime < progress))): case(audios.length && Array.from(audios).some((a) => !a.paused && (a.currentTime - a.previousTime < progress))): videos[0].pausedCount = (videos[0].pausedCount || 0) + 1; log('Paused?', videos[0].pausedCount); if(limit <= videos[0].pausedCount){ Storage.save('stalledlimit', limit + 1, expire); return location.reload(); } break; default: if(1 <= videos[0].pausedCount){ videos[0].pausedCount--; log('Recovering paused?', videos[0].pausedCount); } break; } }, channelPane: { observe: function(){ /* 裏番組一覧を常に改変する */ if(elements.channelPane.modifying === undefined) observe(elements.channelPane, function(records){ if(elements.channelPane.modifying) return; elements.channelPane.modifying = true; core.channelPane.modify();/*アベマによる更新を上書きする*/ animate(function(){elements.channelPane.modifying = false});/*DOM処理の完了後に*/ }, {childList: true, characterData: true, subtree: true}); }, openHide: function(){ /* ユーザーには閉じたように見せない */ html.classList.add('channelPaneHidden');/*開いても隠しておく*/ elements.channelButton.click(); }, scroll: function(a){ let channelPane = elements.channelPane, child = channelPane.firstElementChild; let pHeight = child.offsetHeight, aTop = a.offsetTop, aHeight = a.offsetHeight, innerHeight = window.innerHeight; if(pHeight <= innerHeight) return; let scrollTop = Math.min(Math.max(aTop - (innerHeight / 2) + (aHeight / 2), 0), pHeight - innerHeight -1/*端数対応*/); child.style.transition = 'none'; child.style.transform = `translateY(${scrollTop - channelPane.scrollTop}px)`; channelPane.scrollTop = scrollTop; animate(function(){ child.style.transition = 'transform 500ms ease'; child.style.transform = ''; }); }, modify: function(){ if(!elements.channelPane) return; let channelPane = elements.channelPane, as = site.get.onairs(channelPane), nowonairs = {}/*チャンネルテーブル*/; if(!as.length) return;/*再挑戦のタイミングはobserverに任せる*/ for(let i = 0, a; a = as[i]; i++){ /* 臨時チャンネルが増えていればchannelsを更新する */ if(!channels.some((c) => c.id === a.href.match(/\/([^/]+)$/)[1])) return core.updateChannels(core.channelPane.modify); /* サムネイルサイズの固定値(vw)を求める */ let thumbnail = site.get.thumbnail(a); channelPane.thumbWidth = thumbnail.clientWidth || channelPane.thumbWidth; channelPane.thumbOffsetWidth = thumbnail.parentNode.parentNode.parentNode.offsetWidth || channelPane.thumbOffsetWidth; } /* 各チャンネル */ /* classは公式にclassNameで上書きされてしまうのでdatasetを使う */ for(let i = 0, a; a = as[i]; i++){ nowonairs[a.href.match(/\/([^/]+)$/)[1]] = site.get.nowonair(a); a.dataset.channel = a.href.match(/\/([^/]+)$/)[1]; a.dataset.hidden = (configs.c_visibles[a.dataset.channel]) ? 'false' : 'true'; /* 現在のチャンネルをハイライト */ if(location.href.endsWith(a.href)){ a.dataset.current = 'true'; core.channelPane.scroll(a);/*しかるべきスクロール位置へ*/ }else if(a.dataset.current){ delete a.dataset.current; } /* クリックでのチャンネル切り替えに対応 */ if(!a.listening){ a.listening = true; a.addEventListener('click', function(e){ if(e.isTrusted){ e.preventDefault(); e.stopPropagation(); core.goChannel(a.dataset.channel);/*その後の処理もすべておまかせ*/ } }); } } /* 後続番組を重ねる */ let now = MinuteStamp.now(), end = now + HOUR, ratio = (channelPane.offsetWidth - channelPane.thumbWidth) / HOUR, vw = 100 / window.innerWidth; for(let c = 0, channel; channel = channels[c]; c++){ let nowonair = nowonairs[channel.id]; if(!nowonair) continue;/*臨時チャンネルはnowonairsに入ってない場合がある*/ while(nowonair.nextElementSibling) nowonair.parentNode.removeChild(nowonair.nextElementSibling);/*いったん中身をクリアする*/ for(let p = 0, program; program = channel.programs[p]; p++){ /* 現在からendまでの番組のみ表示させる */ if(program.endAt < now) continue;/*過去*/ if(end < program.startAt) break;/*未来*/ if(program.startAt <= now){/*現在放送中*/ /* タイトルの不要文字列を後まわしに */ let title = site.get.title(nowonair); title.textContent = nowonair.title = Program.modifyTitle(normalize(title.textContent)) || ' '; /* タイトルをツールチップにも */ nowonair.title = title.textContent; /* コンテンツなし */ if(program.noContent) nowonair.classList.add('nocontent'); /* 放送時間を簡略化 */ let duration = site.get.duration(nowonair); duration.textContent = Program.modifyDuration(duration.textContent); nowonair.style.left = channelPane.thumbOffsetWidth * vw + 'vw'; nowonair.style.width = (program.duration - (now - program.startAt)) * ratio * vw + 'vw'; nowonair.previousElementSibling.title = program.title;/*サムネイルのツールチップ*/ nowonair.dataset.once = program.id; if(program.repeat) nowonair.dataset.repeat = program.repeat; if(Notifier.match(program.id)) nowonair.classList.add('active'); nowonair.classList.add('slot'); continue; } /* 以下後続番組 */ let slot = nowonair.cloneNode(true); /* 要素幅 */ slot.style.left = (channelPane.thumbOffsetWidth + ((program.startAt - now) * ratio)) * vw + 'vw'; slot.style.width = (program.duration) * ratio * vw + 'vw'; /* タイトル */ let title = site.get.title(slot); title.textContent = program.title || NOCONTENTS[0]; slot.title = program.title;/*ツールチップ*/ slot.classList.add('slot'); slot.classList[(program.noContent ? 'add' : 'remove')]('nocontent'); /* マーク対応 */ Array.from(title.parentNode.children).forEach((node) => { if(node !== title) title.parentNode.removeChild(node);/*マークをいったん取り除く*/ }); Program.appendMarks(title, program.marks); /* 放送時間と通知 */ let duration = site.get.duration(slot); duration.textContent = program.timeString; slot.dataset.once = program.id; if(program.repeat) slot.dataset.repeat = program.repeat; else delete slot.dataset.repeat; if(Notifier.match(program.id)) slot.classList.add('active'); else slot.classList.remove('active'); if(!program.noContent) duration.parentNode.insertBefore(Notifier.createButton(program), duration); nowonair.parentNode.appendChild(slot); } } }, }, abemaTimetable: { initialize: function(){ site.get.abemaTimetableButton(); let button = elements.abemaTimetableButton; if(!button) return setTimeout(core.abemaTimetable.initialize, 1000); if(configs.replace){ if(button.dataset.replaced === 'true') return; button.addEventListener('click', core.abemaTimetable.buttonListener); button.dataset.replaced = 'true'; }else{ if(button.dataset.replaced === 'false') return; button.removeEventListener('click', core.abemaTimetable.buttonListener); button.dataset.replaced = 'false'; } }, openOnAbemaTimetable: function(){ html.classList.add('abemaTimetable'); $('#splash > div').animate([{opacity: '0'}, {opacity: '1'}], {duration: ABEMATIMETABLEDURATION, fill: 'forwards'}); core.panel.toggle('timetablePanel', core.timetable.createPanel); core.timetable.addCloseListener('closeOnAbemaTimetable', core.abemaTimetable.closeOnAbemaTimetable); }, closeOnAbemaTimetable: function(e){ sequence(function(){ $('#splash > div').animate([{opacity: '1'}, {opacity: '0'}], {duration: ABEMATIMETABLEDURATION, fill: 'forwards'}); }, ABEMATIMETABLEDURATION, function(){ html.classList.remove('abemaTimetable'); }); }, buttonListener: function(e){ /* 既に番組表ページにいるならすぐ開く */ if(location.href.startsWith('https://abema.tv/timetable')){ e.preventDefault(); core.abemaTimetable.openOnAbemaTimetable(); return; } /* ふんわり遷移させる */ if(e.isTrusted){/*実クリック時のみ*/ e.preventDefault(); core.abemaTimetable.volumeDown(); if(elements.closer) elements.closer.click();/*コメントを閉じることでmain消失バグを防ぐ*/ sequence(function(){ html.classList.add('abemaTimetable'); $('#splash > div').animate([{opacity: '0'}, {opacity: '1'}], {duration: ABEMATIMETABLEDURATION, fill: 'forwards'}); }, ABEMATIMETABLEDURATION/*重たい処理に邪魔されず音量をなめらかに下げる猶予*/, function(){ core.panel.toggle('timetablePanel', core.timetable.createPanel); core.timetable.addCloseListener('closeOnAbemaTimetable', core.abemaTimetable.closeOnAbemaTimetable); }, 2500/*映像も隠し音量も下げたので、重たい公式番組表ページに移動するのは落ち着いたあとでよい*/, function(){ elements.abemaTimetableButton.click() }); } }, volumeDown: function(){ /* 音量ダウンの耳心地ベストを検証した末のeaseout */ let media = Array.from([...$$('video[src]'), ...$$('audio[src]')]), step = 10, begin = Date.now(); let easeoutDown = (now, original) => original * Math.pow(1 - Math.min(((now - begin) / ABEMATIMETABLEDURATION), 1), 2);/* (1-X)^2 */ if(!media.length) return; /* 元音量 */ for(let i = 0; media[i]; i++){ media[i].originalVolume = media[i].volume; } /* 音量ダウンタイマーを一気に設置(intervalに比べてタイミングが乱れにくい) */ for(let s = 1; s <= step; s++){ setTimeout(function(){ for(let i = 0; media[i]; i++){ if(s === step) media[i].volume = 0; else media[i].volume = easeoutDown(Date.now(), media[i].originalVolume); } }, ABEMATIMETABLEDURATION * (s/step)); } }, goChannel: function(id){ /* 目的チャンネルで現在放送中の番組を番組表の中から探す */ let button = site.get.abemaTimetableSlotButton(id, core.getProgramIdNowOnAir(id)); if(!button) return location.assign('/now-on-air/' + id); /* クリックして放送ページへのリンクを出現させる */ button.click(); animate(function(){ let a = site.get.abemaTimetableNowOnAirLink(id); if(!a) return location.assign('/now-on-air/' + id); /* ついに念願のチャンネル切り替えイベントを流用できるa要素を手に入れた */ a.click(); /* 放送中のチャンネルに移動するときは番組表を閉じる */ sequence(1000/*ページ遷移に時間がかかるので慌てて番組表を閉じずに*/, function(){ $('#splash > div').animate([{opacity: '1'}, {opacity: '0'}], {duration: ABEMATIMETABLEDURATION, fill: 'forwards'}); core.panel.toggle('timetablePanel', core.timetable.createPanel); }, ABEMATIMETABLEDURATION, function(){ html.classList.remove('abemaTimetable'); }); }); }, }, timetable: { createButton: function(){ let button = elements.channelButton.cloneNode(true); button.dataset.selector = SCRIPTNAME + '-button'; button.title = SCRIPTNAME + ' 番組表'; button.setAttribute('aria-label', SCRIPTNAME); button.appendChild(button.firstElementChild.cloneNode(true)); button.addEventListener('click', function(e){ core.panel.toggle('timetablePanel', core.timetable.createPanel); }, true); elements.channelButton.parentNode.insertBefore(button, elements.channelButton.nextElementSibling) }, createPanel: function(){ let timetablePanel = elements.timetablePanel = createElement(core.html.timetablePanel()); timetablePanel.querySelector('button.ok').addEventListener('click', core.panel.close.bind(null, 'timetablePanel')); core.timetable.buildTimes(); core.timetable.buildDays();/*先に作ったtimesのdisable判定を含む*/ core.timetable.buildTimetable(); core.timetable.searchPane.build(); core.timetable.searchPane.buildNotifications(); core.config.createButton(); core.panel.open('timetablePanel'); core.timetable.listenSelection(); core.timetable.listenMousewheel(); core.timetable.shiftTimetable(); core.timetable.useChannelPane(); setTimeout(core.timetable.setupScrolls, 1000); }, buildDays: function(){ if(!elements.timetablePanel) return; let now = new Date(), starts = [], today = MinuteStamp.justToday(); let getDay = (d) => EDAYS[d.getDay()]; let formatDate = (d) => `${d.getMonth() + 1}月${d.getDate()}日(${JDAYS[d.getDay()]})`; let formatDay = (d) => `${d.getDate()}${JDAYS[d.getDay()]}`; let disableTimes = function(){ let past = MinuteStamp.past(); let inputs = elements.timetablePanel.querySelectorAll('nav .times input:not(.template)'); for(let i = 0; inputs[i]; i++){ if(parseInt(inputs[i].value*HOUR) < past) inputs[i].disabled = true; } }; for(let t = 0, y = now.getFullYear(), m = now.getMonth(), d = now.getDate(); t <= TERM; t++) starts.push(new Date(y, m, d + t)); let days = elements.days = elements.timetablePanel.querySelector('nav .days'); let templates = {input: days.querySelector('input.template'), label: days.querySelector('label.template')}; while(days.children.length > 2/*template*2*/) days.removeChild(days.children[0]); for(let i = 0; starts[i]; i++){ let time = parseInt(starts[i].getTime() / 1000); let input = templates.input.cloneNode(true); let label = templates.label.cloneNode(true); input.classList.remove('template'); label.classList.remove('template'); input.id = 'day-' + time; input.value = time; input.checked = (i === 0); input.addEventListener('click', function(e){ let past = MinuteStamp.past(); let checked = elements.timetablePanel.querySelector('nav .times input:checked'); let start = time; let delta = (!checked) ? past : (checked.value*HOUR); core.timetable.buildTimetable(start + delta); core.timetable.scrollTo(start + delta); }); input.addEventListener('change', function(e){ if(i === 0) return disableTimes(); elements.timetablePanel.querySelectorAll('nav .times input:disabled').forEach((input) => input.disabled = false); }); label.setAttribute('for', input.id); label.classList.add(getDay(starts[i])); label.firstElementChild.textContent = (i === 0) ? formatDate(starts[i]) : formatDay(starts[i]); days.insertBefore(input, templates.input); days.insertBefore(label, templates.input); } disableTimes();/*初期化*/ }, buildTimes: function(){ if(!elements.timetablePanel) return; let deltas = TIMES, past = MinuteStamp.past(), today = MinuteStamp.justToday(); let times = elements.times = elements.timetablePanel.querySelector('nav .times'); let templates = {input: times.querySelector('input.template'), label: times.querySelector('label.template')}; while(times.children.length > 2/*template*2*/) times.removeChild(times.children[0]); for(let i = 0; deltas[i] !== undefined/*0も入ってるので*/; i++){ let input = templates.input.cloneNode(true); let label = templates.label.cloneNode(true); input.classList.remove('template'); label.classList.remove('template'); input.id = 'time-' + deltas[i]; input.value = deltas[i]; input.addEventListener('click', function(e){ let checked = elements.timetablePanel.querySelector('nav .days input:checked'); let start = (checked.value === 'now') ? today : parseInt(checked.value); let delta = deltas[i]*HOUR; core.timetable.buildTimetable(start + delta); core.timetable.scrollTo(start + delta); }); label.setAttribute('for', input.id); label.firstElementChild.textContent = deltas[i] + ':00'; times.insertBefore(input, templates.input); times.insertBefore(label, templates.input); } }, setupScrolls: function(){ if(!elements.timetablePanel) return; let channelsUl = elements.channelsUl, scrollers = elements.scrollers = elements.timetablePanel.querySelector('.scrollers'); let nowButton = elements.timetablePanel.querySelector('button.now'); /* スクロールボタン */ let left = elements.scrollerLeft = scrollers.querySelector('.left'), right = elements.scrollerRight = scrollers.querySelector('.right'); let searchPane = elements.searchPane; right.addEventListener('click', function(e){ if(searchPane.classList.contains('active')) return searchPane.classList.remove('active');/*検索ペインを閉じるボタンとして機能させる*/ core.timetable.scrollTo(channelsUl.scrollTime + HOUR); }); left.addEventListener('click', function(e){ core.timetable.scrollTo(channelsUl.scrollTime - HOUR); }); right.classList.remove('disabled'); /* スクロール先の時間帯で番組表示 */ channelsUl.addEventListener('scroll', function(e){ if(channelsUl.scrolling) return; channelsUl.scrolling = true; setTimeout(function(){ let now = MinuteStamp.now(), past = MinuteStamp.past(), range = (TERM + 1)*DAY - past; let start = now + ((channelsUl.scrollLeft / channelsUl.scrollWidth) * range); core.timetable.buildTimetable(start); channelsUl.scrolling = false; /* バウンシングエフェクト */ let scrollLeftMax = channelsUl.scrollWidth - channelsUl.clientWidth; if(channelsUl.scrollLeft === 0) channelsUl.scrollLeft = BOUNCINGPIXEL; else if(channelsUl.scrollLeft === scrollLeftMax) channelsUl.scrollLeft = scrollLeftMax - BOUNCINGPIXEL; /* Days/Timesの切り替え */ let days = elements.timetablePanel.querySelectorAll('nav .days input:not(.template)'); for(let i = 1; days[i]; i++){ if(start < parseInt(days[i].value)){ days[i - 1].checked = true; days[i - 1].dispatchEvent(new Event('change')); break; }else if(i === days.length - 1){ days[i].checked = true; days[i].dispatchEvent(new Event('change')); } } let times = elements.timetablePanel.querySelectorAll('nav .times input:not(.template)'); for(let i = 1; times[i]; i++){ if(((start + MINUTE/*1分タイマーシフトのズレをカバー*/ + JST) % DAY) / HOUR < parseInt(times[i].value)){ times[i - 1].checked = true; break; }else if(i === times.length - 1){ times[i].checked = true; } } /* 現在時刻に戻るボタン */ if(channelsUl.scrollLeft <= BOUNCINGPIXEL) nowButton.classList.add('disabled'); else if(nowButton.classList.contains('disabled')) nowButton.classList.remove('disabled'); /* スクロールボタンの切り替え */ if(channelsUl.scrollLeft <= BOUNCINGPIXEL) left.classList.add('disabled'); else if(left.classList.contains('disabled')) left.classList.remove('disabled'); if(channelsUl.scrollLeft === scrollLeftMax - BOUNCINGPIXEL) right.classList.add('disabled'); else if(right.classList.contains('disabled')) right.classList.remove('disabled'); }, 100); }, {passive: true});/*Passive Event Listener*/ }, buildTimetable: function(start = MinuteStamp.now()){ let now = MinuteStamp.now(), past = MinuteStamp.past(), range = (configs.span*HOUR), ratio = (100 - NAMEWIDTH) / (configs.span*HOUR); let fullwidth = (((TERM + 1)*DAY - past) / range) * (100 - NAMEWIDTH) + 'vw'; let timetablePanel = elements.timetablePanel, channelsUl = elements.channelsUl = timetablePanel.querySelector('.channels'); let show = function(element){ element.classList.remove('hidden'); element.addEventListener('transitionend', function(e){ element.classList.remove('animate'); }, {once: true}); }; channelsUl.scrollTime = start;/*スクロール用に保持しておく*/ /* 時間帯(目盛りになるので一括して全部作る) */ let timeLi = channelsUl.querySelector('.channels > .time'), timesUl = timeLi.querySelector('.times'); timeLi.style.width = fullwidth; if(timesUl.children.length === 2/*templates*/){ /* 現在時刻に戻るボタン */ let button = timeLi.querySelector('button.now'); button.addEventListener('click', function(e){ core.timetable.scrollTo(MinuteStamp.now()); }); /* 時と日を生成 */ let ht = timesUl.querySelector('.hour.template'), dt = timesUl.querySelector('.day.template'); for(let hour = now - (start - range)%HOUR; hour < now - past + (TERM+1)*DAY; hour += HOUR){ /* 時を作成 */ let hourLi = ht.cloneNode(true); hourLi.classList.remove('template'); hourLi.startAt = hour; hourLi.endAt = hour + HOUR; hourLi.duration = HOUR; hourLi.style.left = Math.max((hour - now) * ratio, 0) + 'vw'; hourLi.style.width = ((hour < now) ? HOUR - (now%HOUR) : HOUR) * ratio + 'vw'; hourLi.addEventListener('click', function(e){ core.timetable.scrollTo(hour); }); let oclock = (((hour+JST)%DAY)/HOUR); if(hour < now){ hourLi.classList.add('nowonair'); hourLi.querySelector('.time').appendChild(MinuteStamp.timeToClock(now)); }else{ hourLi.querySelector('.time').textContent = oclock + ':00'; } timesUl.insertBefore(hourLi, ht); /* 日を作成 */ if(hour < now || oclock === 0){ let dayLi = dt.cloneNode(true); dayLi.classList.remove('template'); dayLi.startAt = (hour < now) ? (now - past) : hour; dayLi.endAt = (hour < now) ? (now - past) + DAY : (hour + DAY); dayLi.duration = DAY; dayLi.style.left = Math.max((hour - now) * ratio, 0) + 'vw'; dayLi.style.width = (((hour < now) ? (DAY - past) : DAY) * ratio) + 'vw'; dayLi.querySelector('.date').textContent = MinuteStamp.minimumDateToString(hour); timesUl.insertBefore(dayLi, hourLi); } } animate(show.bind(null, timeLi)); } /* スワイプによるブラウザバックを防ぐためにバウンシングエフェクトを作る */ if(start === now) animate(() => channelsUl.scrollLeft = BOUNCINGPIXEL); /* 各チャンネル */ let final;/*最後のチャンネルの判定に使う*/ for(let c = channels.length - 1, channel; channel = channels[c]; c--){ if(!configs.c_visibles[channel.id]) continue; final = c; break; } for(let c = 0, delay = 0, channel; channel = channels[c]; c++){ if(!configs.c_visibles[channel.id]) continue; let channelLi = document.getElementById('channel-' + channel.id), current = location.href.endsWith('/now-on-air/' + channel.id); if(!channelLi){ channelLi = channelsUl.querySelector('.channel.template').cloneNode(true); channelLi.classList.remove('template'); channelLi.id = 'channel-' + channel.id; if(current) channelLi.classList.add('current'); channelLi.querySelector('.name').textContent = channel.name; channelLi.querySelector('header').addEventListener('click', function(e){ core.timetable.showProgramData(core.getProgramById(core.getProgramIdNowOnAir(channel.id)));/*移り変わるのでつど取得*/ animate(function(){core.goChannel(channel.id)}); }); channelsUl.insertBefore(channelLi, channelsUl.lastElementChild); } channelLi.style.width = fullwidth; let programsUl = channelLi.querySelector('.programs'); clearTimeout(channelLi.timer), channelLi.timer = setTimeout(function(){/*非同期処理にする*/ /* 表示済みの番組要素の再利用と削除 */ let programLis = programsUl.querySelectorAll('.program:not(.template)');/*nowonairや最初の一画面だけ残す手もるけどshiftTimetableが複雑化するので保留*/ for(let i = 0, li; li = programLis[i]; i++){ if(li.endAt <= start - range/2 || start + range + range < li.startAt) programsUl.removeChild(li); } /* 各番組 */ for(let p = 0, program; program = channel.programs[p]; p++){ if(document.getElementById('program-' + program.id)) continue;/*表示済み*/ if(program.endAt <= now) continue;/*現在より過去*/ if(program.endAt <= start - range/2) continue;/*表示範囲より過去*/ if(start + range + range <= program.startAt) break;/*表示範囲より未来(以降は処理不要)*/ /* programLiを作成 */ let programLi = programsUl.querySelector('.program.template').cloneNode(true); programLi.classList.remove('template'); programLi.id = 'program-' + program.id; programLi.dataset.once = program.id; if(program.repeat) programLi.dataset.repeat = program.repeat; if(program.noContent) programLi.classList.add('nocontent'); let time = programLi.querySelector('.time'), title = programLi.querySelector('.title'); /* 時刻と通知ボタン */ time.textContent = program.startAtString; programLi.insertBefore(Notifier.createButton(program), time); /* タイトル */ title.textContent = program.title || NOCONTENTS[0]; if(program.title === NOCONTENTS[0]){/*空き枠*/ programLi.classList.add('padding'); }else{ if(Notifier.match(program.id)) programLi.classList.add('active'); Program.appendMarks(title, program.marks); programLi.addEventListener('click', function(e){ /* 2度目のクリック時のみ番組開始時刻にスクロールさせる */ if(elements.programDiv && elements.programDiv.programData.id === program.id){/*shownクラスがなぜか判定に使えないので*/ core.timetable.scrollTo(program.startAt); } core.timetable.showProgramData(program); }); } /* 番組の幅を決める */ programLi.startAt = program.startAt; programLi.endAt = program.endAt; programLi.duration = program.duration; if(program.startAt <= now){/*現在放送中*/ programLi.classList.add('nowonair'); programLi.style.left = '0vw'; programLi.style.width = (program.duration - (now - program.startAt)) * ratio + 'vw'; if(program.title === NOCONTENTS[0]) channelLi.classList.add('notonair'); /* 番組情報が空欄なら現在視聴中の番組情報を表示 */ if(current && timetablePanel.isConnected && timetablePanel.querySelector('.panel > .program.nocontent')) core.timetable.showProgramData(program); }else{/*後続番組*/ programLi.style.left = (program.startAt - now) * ratio + 'vw'; programLi.style.width = (program.duration) * ratio + 'vw'; } programsUl.insertBefore(programLi, programsUl.lastElementChild); animate(function(){programLi.classList.remove('hidden')}); } /* 最後に1度だけ */ if(c === final && timetablePanel){ for(let i = 0, channelLis = channelsUl.querySelectorAll('.channel:not(.template)'); channelLis[i]; i++){ if(channelLis[i].classList.contains('hidden')) show(channelLis[i]); } animate(core.timetable.fitWidth); let program = timetablePanel.querySelector('.panel > .program').programData; if(program) core.timetable.highlightProgram(program); } }, (delay++) * (1000/60)); } }, rebuildTimetable: function(){ if(!elements.timetablePanel || !elements.timetablePanel.isConnected) return; let channelsUl = elements.channelsUl = elements.timetablePanel.querySelector('.channels'); for(let i = 0, channelLis = channelsUl.querySelectorAll('.channel:not(.template)'); channelLis[i]; i++){ channelLis[i].parentNode.removeChild(channelLis[i]); } core.timetable.buildTimetable(channelsUl.scrollTime); }, scrollTo: function(start){ let past = MinuteStamp.past(), range = (TERM + 1)*DAY - past, today = MinuteStamp.justToday(), ratio = (start - (today + past)) / range; let channelsUl = elements.channelsUl, scrollLeftMax = channelsUl.scrollWidth - channelsUl.clientWidth; let to = Math.max(0, Math.min(channelsUl.scrollWidth * ratio, scrollLeftMax)), gap = to - channelsUl.scrollLeft; if(gap === 0) return; channelsUl.scrollTime = start; let streams = channelsUl.querySelectorAll('li:not(.template) > .stream'), count = 0; for(let i = 0; streams[i]; i++){ streams[i].style.willChange = 'transform'; streams[i].style.transition = 'transform 1s ease'; } animate(function(){ for(let i = 0; streams[i]; i++){ streams[i].style.transform = `translateX(${-gap}px)`; } }); streams[streams.length - 1].addEventListener('transitionend', function(e){/*疑似スクロールを破綻させないようにタイミングを一致させる*/ for(let i = 0; streams[i]; i++){ streams[i].style.willChange = ''; streams[i].style.transition = 'none';/*scrollLeftを即反映させる*/ streams[i].style.transform = ''; } channelsUl.scrollLeft = Math.ceil(to)/*borderズレを常に回避する*/; }, {once: true}); }, shiftTimetable: function(){ // animateをひとつにするべきなのかもしれないけど let channelsUl = elements.channelsUl; if(!channelsUl || !channelsUl.isConnected) return; if(document.hidden){ if(document.shiftTimetable) return;/*重複防止*/ document.shiftTimetable = true; document.addEventListener('visibilitychange', function(){ document.shiftTimetable = false; core.timetable.shiftTimetable(); }, {once: true}); return; } const change = function(element, left, width, callback){ if(channelsUl.scrollLeft <= BOUNCINGPIXEL && left < 100){ element.style.willChange = 'left'; element.style.transition = 'left 1000ms ease, width 1000ms ease, background 1000ms ease, filter 1000ms ease, padding-left 500ms ease 1000ms'; animate(function(){ element.style.left = left + 'vw'; if(left === 0) element.style.width = width + 'vw'; element.addEventListener('transitionend', function(e){ element.style.willChange = ''; element.style.transition = ''; if(callback) callback(); }, {once: true}); }); }else{ element.style.left = left + 'vw'; if(left === 0) element.style.width = width + 'vw'; if(callback) callback(); } }; let now = MinuteStamp.now(), past = MinuteStamp.past(), end = now + (configs.span*HOUR), ratio = (100 - NAMEWIDTH) / (configs.span*HOUR); /* 各チャンネル */ let channelLis = channelsUl.querySelectorAll('.channels > li:not(.template)'); let oldWidth = channelLis[0].scrollWidth, newlWidthVW = (((TERM + 1)*DAY - past) / (configs.span*HOUR)) * (100 - NAMEWIDTH); for(let c = 0, channelLi; channelLi = channelLis[c]; c++){ channelLi.style.width = newlWidthVW + 'vw';/*チャンネル自体の幅を狭める*/ /* 各番組 */ let slots = channelLi.querySelectorAll('.slot:not(.template)'); for(let s = 0, slotLi; slotLi = slots[s]; s++){ let startAt = slotLi.startAt, endAt = slotLi.endAt, duration = slotLi.duration; switch(true){ case(endAt <= now):/*放送終了*/ change(slotLi, 0, 0, function(e){ if(slots[s + 1]){/*必ずしも隣じゃないけどレアケースなので*/ Slot.highlight(slots[s + 1], 'add', 'nowonair'); if(slotLi.classList.contains('shown')) slots[s + 1].click(); } if(slotLi.isConnected) Slot.highlight(slotLi, 'remove', 'nowonair'), slotLi.parentNode.removeChild(slotLi); if(channelLi.classList.contains('notonair')) channelLi.classList.remove('notonair'); }); break; case(startAt <= now):/*現在放送中*/ change(slotLi, 0, (duration - (now - startAt)) * ratio); /* 現在時刻更新 */ if(slotLi.classList.contains('hour')){ let time = slotLi.querySelector('.time'); time.replaceChild(MinuteStamp.timeToClock(now), time.firstChild); } break; case(startAt < end):/*後続番組*/ default:/*画面外*/ change(slotLi, (startAt - now) * ratio, duration * ratio); break; } } } /* 短くなったぶんだけスクロールする */ if(oldWidth < channelLis[0].scrollWidth) oldWidth += ((DAY * ratio) * window.innerWidth) /100;/*日付が変わったときだけは1日分長くなるので*/ channelsUl.scrollLeft = Math.max(channelsUl.scrollLeft - (oldWidth - channelLis[0].scrollWidth), BOUNCINGPIXEL); /* 現在時刻にいるときは長時間放置で後続番組がなくならないように再構築させる */ if(channelsUl.scrollLeft === BOUNCINGPIXEL) setTimeout(function(){core.timetable.buildTimetable(channelsUl.scrollTime = now)}, 1000); }, showProgramData: function(program){ /* timetable */ let shown = elements.timetablePanel.querySelector('.channels .shown'), show = document.getElementById('program-' + program.id); if(shown) shown.classList.remove('shown'); if(show) show.classList.add('shown'); /* programDiv */ let programDiv = elements.programDiv = elements.timetablePanel.querySelector('.panel > .program'); programDiv.scrollTop = 0; if(programDiv.classList.contains('nocontent')) programDiv.classList.remove('nocontent'); else programDiv.animate([{opacity: 0}, {opacity: 1}], {duration: 250, easing: 'ease-out'}); programDiv.programData = program;/*番組表をハイライトするタイミングで活用*/ /* title */ let title = programDiv.querySelector('.title'); title.textContent = program.title; Array.from(title.parentNode.children).forEach((node) => { if(node !== title) title.parentNode.removeChild(node);/*マークをいったん取り除く*/ }); Program.appendMarks(title, program.marks); /* thumbnails */ let thumbnailsDiv = programDiv.querySelector('.thumbnails'); while(thumbnailsDiv.children.length) thumbnailsDiv.removeChild(thumbnailsDiv.children[0]); if(program.thumbImg){ thumbnailsDiv.appendChild(new Thumbnail(program.displayProgramId, program.thumbImg, 'large').node); } for(let i = 0; program.sceneThumbImgs[i]; i++){ thumbnailsDiv.appendChild(new Thumbnail(program.displayProgramId, program.sceneThumbImgs[i]).node); } /* summary */ let summaryDiv = programDiv.querySelector('.summary'); summaryDiv.querySelector('.channel').textContent = program.channel.name; let dateP = summaryDiv.querySelector('.date'); dateP.querySelector('span').textContent = program.dateString; summaryDiv.querySelector('.highlight').textContent = program.detailHighlight; /* links */ let linksUl = summaryDiv.querySelector('.links'); while(linksUl.children.length > 1/*template*/) linksUl.removeChild(linksUl.firstElementChild); if(program.links){ linksUl.classList.remove('inactive'); let templateLi = linksUl.querySelector('.template'); for(let i = 0; program.links[i]; i++){ let li = templateLi.cloneNode(true), a = li.querySelector('a'); li.classList.remove('template'); a.href = program.links[i].value; a.textContent = program.links[i].title; linksUl.insertBefore(li, templateLi); } }else{ linksUl.classList.add('inactive'); } /* myvideo */ let timeshiftP = summaryDiv.querySelector('.timeshift'); if(program.timeshiftString !== ''){ timeshiftP.classList.remove('inactive'); timeshiftP.querySelector('span').textContent = program.timeshiftString; while(timeshiftP.children.length > 1/*template*/) timeshiftP.removeChild(timeshiftP.firstElementChild); let myvideoButton = MyVideo.createMyvideoButton(program); timeshiftP.insertBefore(myvideoButton, timeshiftP.firstElementChild); }else{ timeshiftP.classList.add('inactive'); } /* group and series */ let now = MinuteStamp.now(), results = [], count = {}; ['group', 'series'].forEach((key, i) => { /* 一致program取得 */ for(let c = 0; channels[c]; c++){ for(let p = 0; channels[c].programs[p]; p++){ if(channels[c].programs[p].endAt < now) continue;/*終了した番組は表示しない*/ if(channels[c].programs[p][key] && channels[c].programs[p][key] === program[key]){ if(1 <= i && results.some((result) => result.id === channels[c].programs[p].id)) continue;/*重複させない*/ results.push(channels[c].programs[p]); count[key] = count[key] + 1 || 1; } } } if(results.length === 1) results.pop(results[0]);/*自分自身の番組しかなければ取り除く*/ else if(1 <= i && !count[key]) while(results.length) results.pop(results[0]);/*同じ内容なら繰り返さない*/ results.sort((a, b) => a.startAt - b.startAt);/*日付順*/ /* タイトルの重複文字列を省略する準備 */ let shorten; if(results.every((r) => r.title === program.title)){ shorten = () => '同'; }else{ /* 区切り文字は/(?=\s)/とし、全タイトル共通文字列と、半数以上のタイトルに共通する文字列を削除する */ let parts = program.title.split(/(?=\s)/), former = {all: '', majority: ''}, latter = {all: '', majority: ''}, n = '\n'; /* 前方一致部分文字列 */ for(let i = 0; parts[i]; i++) if(results.every((r) => r.title.startsWith(former.all + parts[i]))) former.all += parts[i]; for(let i = 0; parts[i]; i++) if(results.filter((r) => r.title.startsWith(former.majority + parts[i])).length >= results.length/2) former.majority += parts[i]; /* 後方一致部分文字列 */ for(let i = parts.length - 1; parts[i]; i--) if(results.every((r) => r.title.endsWith(parts[i] + latter.all))) latter.all = parts[i] + latter.all; for(let i = parts.length - 1; parts[i]; i--) if(results.filter((r) => r.title.endsWith(parts[i] + latter.majority)).length >= results.length/2) latter.majority = parts[i] + latter.majority; /* 削りすぎを回避する */ if((former.majority + latter.majority).length >= program.title.length) former.majority = ''; if((former.majority + latter.majority).length >= program.title.length) latter.majority = ''; shorten = (title) => (title + n).replace(former.majority, '').replace(former.all, '').replace(latter.majority + n, n).replace(latter.all + n, n).trim(); } /* 放送予定リストDOM構築 */ let div = summaryDiv.querySelector(`.${key}`), ul = div.querySelector(`.${key} ul`), templateLi = ul.querySelector('.template'); if(1 <= i && !results.length) div.classList.add('inactive'); else div.classList.remove('inactive'); while(ul.children.length > 1/*template*/) ul.removeChild(ul.children[0]); if(results.length === 0){ let li = templateLi.cloneNode(true); li.classList.remove('template'); li.textContent = '-'; ul.insertBefore(li, templateLi); }else{ for(let p = 0, result; result = results[p]; p++){ let li = templateLi.cloneNode(true), header = li.querySelector('header'); li.classList.remove('template'); if(program.id === result.id) li.classList.add('current'); else header.addEventListener('click', function(e){ core.timetable.showProgramData(result); core.timetable.scrollTo(result.startAt); }); header.insertBefore(Notifier.createButton(result), header.firstElementChild); li.querySelector('.date').textContent = result.justifiedStartAtShortDateString; let title = li.querySelector('.title'); title.textContent = shorten(result.title); Program.appendMarks(title, result.marks); ul.insertBefore(li, templateLi); } } }); /* 1回通知 */ while(dateP.children.length > 1) dateP.removeChild(dateP.firstElementChild); let button = Notifier.createButton(program); dateP.insertBefore(button, dateP.firstElementChild); /* 毎回通知 */ let h3 = summaryDiv.querySelector('h3'); while(h3.children.length > 1) h3.removeChild(h3.firstElementChild); if(program.repeat){ let repeatButton = Notifier.createRepeatAllButton(program); h3.insertBefore(repeatButton, h3.firstElementChild); } /* content */ let content = programDiv.querySelector('.content div'), paragraphs = program.content.split(/\n+/); while(content.children.length) content.removeChild(content.children[0]); for(let i = 0; paragraphs[i]; i++){ let p = document.createElement('p'); p.textContent = paragraphs[i]; linkify(p); content.appendChild(p); } /* casts and crews */ let searchInput = elements.timetablePanel.querySelector('nav > .search input'); ['casts', 'crews'].forEach((key) => { let ul = programDiv.querySelector(`.${key} ul`); while(ul.children.length) ul.removeChild(ul.children[0]); for(let i = 0; program[key][i]; i++){ let li = document.createElement('li'); li.textContent = program[key][i]; Program.linkifyNames(li, function(e){ core.timetable.searchPane.search(e.target.textContent); }); ul.appendChild(li); } if(ul.children.length === 0){ let li = document.createElement('li'); li.textContent = '-'; ul.appendChild(li); } }); /* copyrights */ programDiv.querySelector('.copyrights').textContent = program.copyrights.join(', '); /* highlight */ core.timetable.highlightProgram(program); }, highlightProgram: function(program){ let oldShown = elements.channelsUl.querySelector('.program.shown'); if(oldShown) Slot.highlight(oldShown, 'remove', 'shown'); let newShown = document.getElementById('program-' + program.id); if(newShown) Slot.highlight(newShown, 'add', 'shown'); }, listenSelection: function(){ let programDiv = elements.timetablePanel.querySelector('.panel > .program'); let select = function(e){ let selection = window.getSelection(), selected = selection.toString(); if(selection.isCollapsed) return; if(0 <= selected.indexOf('\n')) return; let value = selected.trim(); if(value === '') return; core.timetable.searchPane.search(value); }; programDiv.addEventListener('mousedown', function(e){ programDiv.addEventListener('mouseup', function(e){ animate(function(){select(e)});/*ダブルクリックでのテキスト選択をanimateで確実に補足*/ }, {once: true}); }); }, listenMousewheel: function(){ let channelsUl = elements.channelsUl; channelsUl.addEventListener('wheel', function(e){ if(0 < Math.abs(e.deltaX)) return;/*通常の左右ホイール・スワイプ*/ if(Math.abs(e.deltaY) < 1) return;/*ホイール量が小さすぎる*/ if(e.target.localName === 'h2') return; channelsUl.scrollLeft += e.deltaY; }, {passive: true}); }, useChannelPane: function(){ /* ChannelPaneのチャンネル切り替えイベントを流用できるようにしておく */ if(location.href.includes('/now-on-air/')){ if(site.get.screenCommentScroller()) return;/*既に開いてくれているはず*/ core.channelPane.openHide(); core.timetable.addCloseListener('channelPaneHidden', function(){ elements.closer.click(); html.classList.remove('channelPaneHidden'); }); } }, addCloseListener: function(name, listener){ elements.timetablePanel.querySelector('button.ok').addEventListener('click', listener); if(!elements.panels['listening-' + name]){ elements.panels['listening-' + name] = true; window.addEventListener('keypress', function(e){ if(['input', 'textarea'].includes(document.activeElement.localName)) return; if(elements.timetablePanel && e.key === 'Escape') return listener(); }); } }, fitWidth: function(){ if(!elements.timetablePanel || !elements.timetablePanel.isConnected) return; let timetablePanel = elements.timetablePanel, fits = timetablePanel.querySelectorAll('.fit'); for(let i = 0; fits[i]; i++){ if(fits[i].scrollWidth < fits[i].clientWidth) fits[i].style.transform = ''; else fits[i].style.transform = `scaleX(${fits[i].clientWidth / fits[i].scrollWidth})`; } }, searchPane: { build: function(){ let searchInput = elements.searchInput = elements.timetablePanel.querySelector('nav > .search input[type="search"]'); let searchButton = elements.searchButton = elements.timetablePanel.querySelector('nav > .search button.search'); let searchPane = elements.searchPane = elements.timetablePanel.querySelector('.programs > .search'); /* 検索 */ searchInput.addEventListener('keypress', function(e){ if(e.key === 'Escape') return searchPane.classList.remove('active'); if(e.key !== 'Enter') return; let value = searchInput.value.trim(); if(value === ''){ searchPane.classList.remove('active'); searchPane.dataset.mode = ''; return; } core.timetable.searchPane.search(value);/*marks絞りなしで一括取得*/ }); searchButton.addEventListener('click', function(e){ let value = searchInput.value.trim(); if(value === ''){ searchPane.classList.remove('active'); searchPane.dataset.mode = ''; return; } core.timetable.searchPane.search(value);/*marks絞りなしで一括取得*/ }); }, search: function(value, marks = site.marks){ let searchInput = elements.searchInput, searchPane = elements.searchPane, ul = searchPane.querySelector('ul'); value = value.trim(); searchInput.value = value; ul.results = core.searchPrograms(value);/*全件取得してDOMプロパティに渡しておく(絞り込みはlistSearchResultsでinputを判定して行う)*/ core.timetable.searchPane.buildSearchHeader(); core.timetable.searchPane.updateSearchFillters(value, marks); core.timetable.searchPane.listSearchResults(value); searchPane.classList.add('active'); searchPane.dataset.mode = 'search'; }, buildSearchHeader: function(){ let searchInput = elements.searchInput, searchPane = elements.searchPane; while(searchPane.children.length > 1/*ul*/) searchPane.removeChild(searchPane.children[0]); searchPane.insertBefore(createElement(core.html.searchHeader()), searchPane.firstElementChild); /* 絞り込みDOM生成 */ let filtersP = searchPane.querySelector('.filters'); let it = filtersP.querySelector('input.template'), lt = filtersP.querySelector('label.template'); site.marks.forEach(function(key){ let input = it.cloneNode(true); let label = lt.cloneNode(true); input.classList.remove('template'); label.classList.remove('template'); input.id = 'mark-' + key; input.value = key; label.setAttribute('for', 'mark-' + key); label.appendChild(createElement(core.html.marks[key]())); filtersP.insertBefore(input, it); filtersP.insertBefore(label, it); }); /* eventListener付与 */ let labels = filtersP.querySelectorAll('label:not(.template)'); labels.forEach((label) => { /* 連続で次々クリックするとマウスポインタのズレによるclick判定漏れが起きやすいので、mousedownで処理する */ label.addEventListener('mousedown', function(e){ let input = label.previousElementSibling; input.checked = !input.checked; core.timetable.searchPane.listSearchResults(searchInput.value); }); label.addEventListener('click', function(e){ e.preventDefault(); }); }); }, updateSearchFillters: function(value, marks){ let searchPane = elements.searchPane, labels = searchPane.querySelectorAll('.filters label:not(.template)'); labels.forEach((label) => { let input = label.previousElementSibling; input.checked = (marks.some((mark) => mark === input.value)); if(notifications.search[value] && notifications.search[value].includes(input.value)) label.classList.add('notify'); else label.classList.remove('notify'); }); }, listSearchResults: function(value){ let searchPane = elements.searchPane, summary = searchPane.querySelector('.summary'); let ul = searchPane.querySelector('ul'); /* 絞り込み */ let marks = [], filters = searchPane.querySelectorAll('.filters input:not(.template)'); filters.forEach((filter) => {if(filter.checked === true) marks.push(filter.value)}); let filteredResults = ul.results.filter((program) => { if(marks.some((mark) => program.marks[mark] !== undefined)) return true; if(marks.includes('none') && Object.keys(program.marks).length === 0) return true; }); /* 検索結果リスト */ core.timetable.searchPane.listPrograms(ul, filteredResults); core.timetable.searchPane.updateResultCount(filteredResults.length); /* 検索結果を常に通知する */ while(summary.children.length > 1/*count*/) summary.removeChild(summary.lastElementChild); summary.appendChild(Notifier.createSearchAllButton(value, marks)); }, buildNotifications: function(){ let searchInput = elements.searchInput, searchPane = elements.searchPane, ul = searchPane.querySelector('ul'); let button = elements.notificationsButton = elements.timetablePanel.querySelector('nav button.notifications'); Notifier.updateCount(); button.addEventListener('click', function(e){ if(searchPane.dataset.mode === 'notifications'){ searchPane.classList.remove('active'); searchPane.dataset.mode = ''; return; } searchPane.classList.add('active'); searchPane.dataset.mode = 'notifications'; searchInput.value = ''; ul.results = notifications.programs;/*DOMプロパティとして検索結果を渡す約束*/ core.timetable.searchPane.buildNotificationsHeader(); core.timetable.searchPane.listAllNotifications(); }); }, buildNotificationsHeader: function(){ let searchPane = elements.searchPane, header = searchPane.querySelector('header'); if(header) searchPane.removeChild(header); searchPane.insertBefore(createElement(core.html.notificationsHeader()), searchPane.firstElementChild); /* eventListener付与 */ let labels = searchPane.querySelectorAll('nav.tabs > label'); let actions = { all: core.timetable.searchPane.listAllNotifications, once: core.timetable.searchPane.listOnceNotifications, repeat: core.timetable.searchPane.listRepeatNotifications, search: core.timetable.searchPane.listSearchNotifications, } labels.forEach((label) => { /* 連続で次々クリックするとマウスポインタのズレによるclick判定漏れが起きやすいので、mousedownで処理する */ label.addEventListener('mousedown', function(e){ let input = label.previousElementSibling; input.checked = true; actions[input.value](); }); label.addEventListener('click', function(e){ e.preventDefault(); }); }); }, listAllNotifications: function(){ core.timetable.searchPane.listDaysNotifications(notifications.programs); core.timetable.searchPane.updateResultCount(notifications.programs.length); }, listOnceNotifications: function(){ let filteredResults = notifications.programs.filter((p) => { if(!Notifier.matchOnce(p.once)) return false; if(Notifier.matchRepeat(p.repeat)) return false;/*毎回通知は含めない*/ return true; }); core.timetable.searchPane.listDaysNotifications(filteredResults); core.timetable.searchPane.updateResultCount(filteredResults.length); }, listDaysNotifications: function(programs){ let searchPane = elements.searchPane, ul = searchPane.querySelector('ul'); let labels = ['きょう', 'あした', 'あさって以降'], days = {}, today = MinuteStamp.justToday(); labels.forEach((label) => days[label] = []); programs.forEach((p) => { switch(true){ case(p.startAt < today + DAY*1): return days[labels[0]].push(p); case(p.startAt < today + DAY*2): return days[labels[1]].push(p); default: return days[labels[2]].push(p); } }); while(ul.children.length > 0) ul.removeChild(ul.children[0]); labels.forEach((key) => { let li = createElement(core.html.dayListItem()), h2 = li.querySelector('h2'); h2.textContent = key; core.timetable.searchPane.listPrograms(li.querySelector('ul'), days[key]); ul.appendChild(li); }); }, listRepeatNotifications: function(){ let searchPane = elements.searchPane, ul = searchPane.querySelector('ul'); let repeats = {}, count = 0; notifications.programs.forEach((p) => { if(!Notifier.matchRepeat(p.repeat)) return; if(MAXRESULTS <= count) return count++; if(!repeats[p.repeat]) repeats[p.repeat] = []; repeats[p.repeat].push(p); count++; }); Object.keys(notifications.repeat).forEach((key) => { if(!repeats[key]) repeats[key] = []; }); while(ul.children.length > 0) ul.removeChild(ul.children[0]); Object.keys(repeats).forEach((key) => { let li = createElement(core.html.repeatListItem()), h2 = li.querySelector('h2'); h2.querySelector('.title').textContent = notifications.repeat[key]; h2.insertBefore(Notifier.createRepeatAllButton(repeats[key][0] || { /* 期間内に番組がなくても repeat, title さえあればボタン生成できる */ repeat: key, title: notifications.repeat[key], }), h2.firstChild); core.timetable.searchPane.listPrograms(li.querySelector('ul'), repeats[key]); ul.appendChild(li); }); core.timetable.searchPane.updateResultCount(count); }, listSearchNotifications: function(){ let searchPane = elements.searchPane, ul = searchPane.querySelector('ul'); let searches = {}, programs = [], limit = Infinity; Object.keys(notifications.search).forEach((key) => { searches[key] = core.searchPrograms(key, notifications.search[key]); programs = programs.concat(searches[key]); }); if(MAXRESULTS < programs.length) limit = programs[MAXRESULTS - 1].startAt; while(ul.children.length > 0) ul.removeChild(ul.children[0]); Object.keys(searches).sort((a, b) => { if(searches[a][0] && searches[b][0]) return searches[a][0].startAt - searches[b][0].startAt;/*放送開始の早い順*/ else if(searches[a].length) return -1;/*検索に該当する番組がなければあとまわし*/ else if(searches[b].length) return +1; else return b < a;/*該当する番組がないもの同士では辞書順*/ }).forEach((key) => { let marks = notifications.search[key].map((name) => core.html.marks[name]()); let li = createElement(core.html.searchListItem(key, marks.join(''))), h2 = li.querySelector('h2'); h2.insertBefore(Notifier.createSearchButton(key), h2.firstChild); core.timetable.searchPane.listPrograms(li.querySelector('ul'), searches[key].filter((p) => p.startAt <= limit)); ul.appendChild(li); }); core.timetable.searchPane.updateResultCount(programs.length); }, listPrograms: function(ul, programs){ let searchPane = elements.searchPane, summary = searchPane.querySelector('.summary'); /* 前準備 */ searchPane.scrollTop = 0; [summary, ul].forEach((e) => e.animate([{opacity: 0}, {opacity: 1}], {duration: 250, easing: 'ease-out'})); while(ul.children.length > 0) ul.removeChild(ul.children[0]); if(programs.length === 0){ let li = createElement(core.html.noProgramListItem()); ul.appendChild(li); } for(let p = 0; programs[p] && p < MAXRESULTS; p++){ let li = createElement(core.html.programListItem()); let title = li.querySelector('.title'); title.textContent = programs[p].title; Program.appendMarks(title, programs[p].marks); let data = li.querySelector('.data'); data.insertBefore(Notifier.createButton(programs[p]), data.firstElementChild); li.querySelector('.date').textContent = programs[p].justifiedDateString; li.querySelector('.channel').textContent = programs[p].channel.name; let thumbnail = li.querySelector('.thumbnail'); /* 遅延読み込み */ let observer = new IntersectionObserver(function(entries){ if(!entries[0].isIntersecting) return; observer.disconnect(); thumbnail.appendChild(new Thumbnail(programs[p].displayProgramId, programs[p].thumbImg, 'large').node); }, {root: searchPane, rootMargin: '50%'}); observer.observe(thumbnail); li.addEventListener('click', function(e){ core.timetable.showProgramData(programs[p]); core.timetable.scrollTo(programs[p].startAt); }); ul.appendChild(li); } }, updateResultCount: function(length){ let searchPane = elements.searchPane, count = searchPane.querySelector('.count'); switch(true){ case(length === 0): count.textContent = `見つかりませんでした`; break; case(length <= MAXRESULTS): count.textContent = `${length}件見つかりました`; break; case(MAXRESULTS < length): count.textContent = `${MAXRESULTS}件以上見つかりました`; break; } }, }, }, getProgramById: function(id){ for(let c = 0, channel; channel = channels[c]; c++){ for(let p = 0, program; program = channel.programs[p]; p++){ if(program.id === id) return program; } } }, matchProgram: function(program, value, marks = []){ if(program.noContent) return false; let words = normalize(value.toLowerCase()).split(/\s+/); if(!words.every((word) => { return [ program.channel.name, program.title, ...program.casts || [], ...program.crews || [], ].some((p) => (0 <= p.toLowerCase().indexOf(word))); })) return false; if(marks.length === 0) return true; if(marks.some((mark) => program.marks[mark] !== undefined)) return true; if(marks.includes('none') && Object.keys(program.marks).length === 0) return true; }, searchPrograms: function(value, marks = []){ let now = MinuteStamp.now(), results = []; for(let c = 0, channel; channel = channels[c]; c++){ for(let p = 0, program; program = channel.programs[p]; p++){ if(!configs.c_visibles[program.channel.id]) continue; if(program.endAt <= now) continue; if(program.noContent) continue; if(core.matchProgram(program, value, marks)) results.push(program); } } results.sort((a, b) => a.startAt - b.startAt);/*日付順*/ return results; }, getProgramIdNowOnAir: function(channelId){ for(let now = MinuteStamp.now(), c = 0, channel; channel = channels[c]; c++){ if(channel.id !== channelId) continue; for(let p = 0, program; program = channel.programs[p]; p++){ if(program.endAt < now) continue; if(now < program.startAt) break;/*念のため*/ return program.id; } } }, config: { read: function(){ /* 保存済みの設定を読む */ configs = Storage.read('configs') || {}; /* 未定義項目をデフォルト値で上書きしていく */ Object.keys(CONFIGS).forEach((key) => {if(configs[key] === undefined) configs[key] = CONFIGS[key].DEFAULT}); }, save: function(new_config){ configs = {};/*CONFIGSに含まれた設定値のみ保存する*/ /* CONFIGSを元に文字列を型評価して値を格納していく */ Object.keys(CONFIGS).forEach((key) => { /* 値がなければデフォルト値 */ if(new_config[key] === "") return configs[key] = CONFIGS[key].DEFAULT; switch(CONFIGS[key].TYPE){ case 'bool': configs[key] = (new_config[key]) ? 1 : 0; break; case 'int': configs[key] = parseInt(new_config[key]); break; case 'float': configs[key] = parseFloat(new_config[key]); break; default: configs[key] = new_config[key]; break; } }); Storage.save('configs', configs); }, createButton: function(){ elements.configButton = elements.timetablePanel.querySelector('button.config'); elements.configButton.addEventListener('click', core.panel.toggle.bind(null, 'configPanel', core.config.createPanel)); }, createPanel: function(){ elements.configPanel = createElement(core.html.configPanel()); let channelsUl = elements.configPanel.querySelector('.channels'), templateLi = channelsUl.querySelector('li.template'); for(let i = 0; channels[i]; i++){ let li = templateLi.cloneNode(true); li.classList.remove('template'); let input = li.querySelector('input'); input.value = channels[i].id; input.checked = configs.c_visibles[channels[i].id]; li.querySelector('label > span').textContent = channels[i].name; channelsUl.insertBefore(li, templateLi); } channelsUl.removeChild(templateLi); elements.configPanel.querySelector('button.cancel').addEventListener('click', core.panel.close.bind(null, 'configPanel')); elements.configPanel.querySelector('button.save').addEventListener('click', function(){ let inputs = elements.configPanel.querySelectorAll('input'), new_configs = {}; for(let i = 0, input; input = inputs[i]; i++){ switch(CONFIGS[input.name].TYPE){ case('bool'): new_configs[input.name] = (input.checked) ? 1 : 0; break; case('object'): if(!new_configs[input.name]) new_configs[input.name] = {}; new_configs[input.name][input.value] = (input.checked) ? 1 : 0; break; default: new_configs[input.name] = input.value; break; } } core.config.save(new_configs); core.panel.close('configPanel') /* 新しい設定値で再スタイリング */ core.addStyle(); core.channelPane.modify(); core.abemaTimetable.initialize(); core.timetable.rebuildTimetable(); Notifier.sync(); }, true); elements.configPanel.querySelector('input[name="n_change"]').addEventListener('click', function(e){ let n_overlap = elements.configPanel.querySelector('input[name="n_overlap"]'); n_overlap.disabled = !n_overlap.disabled; n_overlap.parentNode.parentNode.classList.toggle('disabled'); }, true); core.panel.open('configPanel'); }, }, panel: { createPanels: function(){ if(elements.panels) return; elements.panels = createElement(core.html.panels()); elements.panels.dataset.panels = 0; document.body.appendChild(elements.panels); }, open: function(key){ let target = null; for(let i = PANELS.indexOf(key) + 1; PANELS[i] && !target; i++) if(elements[PANELS[i]]) target = elements[PANELS[i]]; elements[key].classList.add('hidden'); elements.panels.insertBefore(elements[key], target); animate(function(){ elements.panels.dataset.panels = parseInt(elements.panels.children.length); elements[key].classList.remove('hidden'); }); elements.panels.listeningKeypress = elements.panels.listeningKeypress || []; if(!elements.panels.listeningKeypress[key]){ elements.panels.listeningKeypress[key] = true; window.addEventListener('keypress', function(e){ if(['input', 'textarea'].includes(document.activeElement.localName)) return; if(elements[key] && e.key === 'Escape') core.panel.close(key); }); } }, close: function(key){ elements[key].classList.add('hidden'); elements[key].addEventListener('transitionend', function(e){ if(!elements[key]) return; elements.panels.dataset.panels = parseInt(elements.panels.children.length - 1); elements.panels.removeChild(elements[key]); elements[key] = null; }, {once: true}); }, toggle: function(key, create){ (!elements[key]) ? create() : core.panel.close(key); }, }, addStyle: function(){ let style = createElement(core.html.style()); document.head.appendChild(style); if(elements.style && elements.style.isConnected) document.head.removeChild(elements.style); elements.style = style; }, html: { marks: {/*live(生), newcomer(新), first(初), last(終), bingeWatching(一挙), recommendation(注目), none(なし)*/ live: () => `<span class="mark live" ><svg height="14" width="14"><use xlink:href="/images/icons/text_live_rect.svg#svg-body"></use></svg><svg height="14" width="14"><use xlink:href="/images/icons/text_live_path.svg#svg-body"></use></svg></span>`, newcomer: () => `<span class="mark newcomer"><svg height="14" width="14"><use xlink:href="/images/icons/text_newcomer_rect.svg#svg-body"></use></svg><svg height="14" width="14"><use xlink:href="/images/icons/text_newcomer_path.svg#svg-body"></use></svg></span>`, first: () => `<svg class="mark first" height="14" width="14"><use xlink:href="/images/icons/text_new.svg#svg-body"></use></svg>`, last: () => `<svg class="mark last" height="14" width="14"><use xlink:href="/images/icons/text_end.svg#svg-body"></use></svg>`, bingeWatching: () => `<svg class="mark bingeWatching" height="14" width="23.333333333333336"><use xlink:href="/images/icons/text_binge_watching.svg#svg-body"></use></svg>`, recommendation: () => `<svg class="mark recommendation" height="14" width="23.333333333333336"><use xlink:href="/images/icons/text_recommendation.svg#svg-body"></use></svg>`, none: () => `<span class="mark none">なし</span>`, }, myvideoButton: () => ` <button class="myvideo" data-title-default="マイビデオに追加する" data-title-active="マイビデオを解除する"> <svg width="16" height="16"> <use class="plus" xlink:href="/images/icons/plus.svg#svg-body"></use> <use class="checked" xlink:href="/images/icons/checkmark.svg#svg-body"></use> </svg> </button> `, repeatAllButton: () => ` <button class="repeat_all" data-title-default="毎回通知を受け取る" data-title-active="毎回通知を解除する"><svg width="20" height="12"><use xlink:href="/images/icons/repeat.svg#svg-body"></use></svg></button> `, playButton: () => ` <button class="play" title="現在放送中"><svg width="17" height="17"><use xlink:href="/images/icons/play.svg#svg-body"></use></svg></button> `, notifyButton: () => ` <button class="notify" data-title-default="通知を受け取る" data-title-once="通知を解除する" data-title-repeat="毎回通知に登録済み" data-title-search="登録済みの検索通知を確認する"> <svg width="17" height="17"> <use class="plus" xlink:href="/images/icons/alarm_clock_plus.svg#svg-body"></use> <use class="checked" xlink:href="/images/icons/alarm_clock_checkmark.svg#svg-body"></use> <use class="repeat" xlink:href="/images/icons/repeat.svg#svg-body"></use> <use class="search" xlink:href="/images/icons/search.svg#svg-body"></use> </svg> </button> `, searchAllButton: (value, marks) => ` <button class="search_all" data-title-default="検索結果を常に通知する" data-title-active="検索結果の通知を解除する"><svg width="17" height="17"><use xlink:href="/images/icons/search.svg#svg-body"></use></svg>${value} (${marks}) を常に通知</button> `, clock: (hours, minutes) => `<span class="clock">${hours}<span class="blink">:</span>${minutes}</span>`, searchHeader: () => ` <header> <p class="filters"> <input class="template" type="checkbox" name="filter" checked><label class="template"></label> </p> <p class="summary"><span class="count"></span></p> </header> `, notificationsHeader: () => ` <header> <nav class="tabs"> <input type="radio" name="notifications" value="all" id="notifications-all" checked><label for="notifications-all" >すべて</label> <input type="radio" name="notifications" value="once" id="notifications-once" ><label for="notifications-once" ><svg width="17" height="17"><use xlink:href="/images/icons/alarm_clock_checkmark.svg#svg-body"></use></svg>1回通知</label> <input type="radio" name="notifications" value="repeat" id="notifications-repeat" ><label for="notifications-repeat"><svg width="20" height="12"><use xlink:href="/images/icons/repeat.svg#svg-body"></use></svg>毎回通知</label> <input type="radio" name="notifications" value="search" id="notifications-search" ><label for="notifications-search"><svg width="17" height="17"><use xlink:href="/images/icons/search.svg#svg-body"></use></svg>検索通知</label> </nav> <p class="summary"><span class="count"></span></p> </header> `, programListItem: () => ` <li class="program"> <p class="thumbnail"></p> <h2><span class="title"></span></h2> <p class="data"><span class="date"></span><span class="channel"></span></p> </li> `, noProgramListItem: () => ` <li class="noprogram">該当する番組はありません</li> `, dayListItem: () => ` <li class="day"> <h2></h2> <ul></ul> </li> `, repeatListItem: () => ` <li class="repeat"> <h2><span class="title"></span></h2> <ul></ul> </li> `, searchListItem: (value, marks) => ` <li class="search"> <h2><span class="key">${value} (${marks})</span></h2> <ul></ul> </li> `, timetablePanel: () => ` <div class="panel" id="${SCRIPTNAME}-timetable-panel"> <header> <h1>番組表</h1> <p class="buttons"><button class="config" title="${SCRIPTNAME} 設定"><svg width="20" height="20"><use xlink:href="/images/icons/config.svg#svg-body"></use></svg></button></p> </header> <div class="program nocontent"> <h2><span class="title">番組タイトル</span></h2> <div class="thumbnails"></div> <div class="summary"> <p class="channel">チャンネル</p> <p class="date"><span>放送日時</span></p> <p class="timeshift"><span>見逃し視聴</span></p> <p class="highlight"></p> <ul class="links"> <li class="template"><a></a></li> </ul> <div class="group"> <h3><span>今後${TERMLABEL}の放送予定</span></h3> <ul> <li class="template"><header><span class="date"></span><span class="title"></span></header></li> </ul> </div> <div class="series"> <h3>(再放送などを含む)</h3> <ul> <li class="template"><header><span class="date"></span><span class="title"></span></header></li> </ul> </div> </div> <div class="content"> <h3>番組概要</h3> <div></div> </div> <div class="casts"> <h3>キャスト</h3> <ul></ul> </div> <div class="crews"> <h3>スタッフ</h3> <ul></ul> </div> <p class="copyrights"></p> </div> <nav> <div class="timeshift"> <p class="days"><input class="template" type="radio" name="day"><label class="template"><span class="fit"></span></label></p> <p class="times"><input class="template" type="radio" name="time"><label class="template"><span class="fit"></span></label></p> </div> <p class="search"> <input type="search" name="q" placeholder="検索 (番組名、チャンネル名、キャスト、スタッフ)"><button class="search"><svg width="17" height="17"><use xlink:href="/images/icons/search.svg#svg-body"></use></svg></button> <button class="notifications"><svg width="17" height="17"><use class="checked" xlink:href="/images/icons/alarm_clock_checkmark.svg#svg-body"></use></svg><span class="count"></span></button> </p> </nav> <div class="programs"> <div class="search"> <ul> </ul> </div> <ul class="channels"> <li class="time hidden animate"> <header><button class="now disabled" title="現在時刻に戻る"><span class="arrows">‹‹</span></button></header> <ul class="stream times"> <li class="slot hour template"><span class="time"></span></li> <li class="slot day template"><span class="date"></span></li> </ul> </li> <li class="channel template hidden animate"> <header><h2 class="name fit"></h2></header> <ul class="stream programs"> <li class="slot program template hidden"><span class="time"></span><span class="title"></span></li> </ul> </li> </ul> <p class="scrollers"> <button class="left disabled" aria-label="表示を左に移動"><svg height="20" width="12"><use xlink:href="/images/icons/chevron_left.svg#svg-body"></use></svg></button> <button class="right disabled" aria-label="表示を右に移動"><svg height="20" width="12"><use xlink:href="/images/icons/chevron_right.svg#svg-body"></use></svg></button> </p> </div> <p class="buttons"><button class="ok primary">OK</button></p> </div> `, configPanel: () => ` <div class="panel" id="${SCRIPTNAME}-config-panel"> <h1>${SCRIPTNAME}設定</h1> <fieldset> <legend>番組表パネル</legend> <p><label>透明度(%): <input type="number" name="transparency" value="${configs.transparency}" min="0" max="100" step="5"></label></p> <p><label>番組表の高さ(%)(文字サイズ連動): <input type="number" name="height" value="${configs.height}" min="5" max="95" step="5"></label></p> <p><label>番組表の時間幅(時間): <input type="number" name="span" value="${configs.span}" min="1" max="24" step="1"></label></p> <p><label>アベマ公式の番組表を置き換える: <input type="checkbox" name="replace" value="${configs.replace}" ${configs.replace ? 'checked' : ''}></label></p> </fieldset> <fieldset> <legend>通知(abema.tvを開いているときのみ)</legend> <p><label>番組開始何秒前に通知するか(秒): <input type="number" name="n_before" value="${configs.n_before}" min="0" max="600" step="1"></label></p> <p><label>自動でチャンネルも切り替える: <input type="checkbox" name="n_change" value="${configs.n_change}" ${configs.n_change ? 'checked' : ''}></label></p> <p class="sub ${configs.n_change ? '' : 'disabled'}"><label>時間帯が重なっている時は通知のみ: <input type="checkbox" name="n_overlap" value="${configs.n_overlap}" ${configs.n_overlap ? 'checked' : ''} ${configs.n_change ? '' : 'disabled'}></label></p> <p><label>アベマ公式の通知と共有する: <input type="checkbox" name="n_sync" value="${configs.n_sync}" ${configs.n_sync ? 'checked' : ''}></label></p> </fieldset> <fieldset> <legend>表示するチャンネル</legend> <ul class="channels"> <li class="template"><label><input type="checkbox" name="c_visibles" value="id"><span>チャンネル名</span></label></li> </ul> </fieldset> <p class="buttons"><button class="cancel">キャンセル</button><button class="save primary">保存</button></p> </div> `, panels: () => ` <div class="panels" id="${SCRIPTNAME}-panels"></div> `, style: () => ` <style type="text/css"> /* 共通変数 */ /* visible_channels: ${configs.visible_channels = Object.keys(configs.c_visibles).filter((id) => configs.c_visibles[id] === 1).length || 25} */ /* channelPane_width: ${configs.channelPane_width = 25} */ /* channelPane_rowheight: ${configs.channelPane_roweight = 100 / 15.5} (.5は番組表リンクの高さ) */ /* channelPane_thumbheight: ${configs.channelPane_thumbheight = configs.channelPane_roweight * .750} */ /* channelPane_padding: ${configs.channelPane_padding = configs.channelPane_roweight * .125} */ /* channelPane_lineheight: ${configs.channelPane_lineheight = configs.channelPane_roweight * .375} */ /* channelPane_fontsize: ${configs.channelPane_fontsize = configs.channelPane_roweight * .225} */ /* opacity: ${configs.opacity = 1 - (configs.transparency / 100)} */ /* scrollbarWidth: ${configs.scrollbarWidth = getScrollbarWidth()} */ /* rowheight: ${configs.rowheight = configs.height / (configs.visible_channels + 1)} */ /* rowfontsize: ${configs.rowfontsize = Math.min(2.0, configs.rowheight * .6)} */ /* lineheight: ${configs.lineheight = 3.0} */ /* fontsize: ${configs.fontsize = 1.8} */ /* search_lineheight: ${configs.search_lineheight = Math.max(1.8, configs.rowfontsize * Math.min(configs.height/50, 1) * 1.5)} */ /* search_fontsize: ${configs.search_fontsize = Math.max(1.2, configs.rowfontsize * Math.min(configs.height/50, 1))} */ /* transparentGray: ${configs.transparentGray = `rgba(255,255,255,.5)`} */ /* link_color: ${configs.link_color = `rgba( 81,195, 0,1)`} */ /* listed_background: ${configs.listed_background = `rgba(112,112,112,${configs.opacity})`} */ /* listed_backgroundHover: ${configs.listed_backgroundHover = `rgba(112,112,112,${configs.opacity / 2})`} */ /* times_background: ${configs.times_background = `rgba( 64, 64, 64,${configs.opacity / 2})`} */ /* nowOnAir_background: ${configs.nowOnAir_background = `rgba(112,112,112,${configs.opacity})`} */ /* comming_background: ${configs.comming_background = `rgba( 64, 64, 64,${configs.opacity})`} */ /* noContent_background: ${configs.noContent_background = `rgba( 0, 0, 0,${configs.opacity})`} */ /* hover_background: ${configs.hover_background = `rgba( 61,146, 0,${configs.opacity})`} */ /* current_background: ${configs.current_background = `rgba( 81,195, 0,${configs.opacity})`} */ /* scroller_background: ${configs.scroller_background = `rgba(255,255,255,${configs.opacity})`} */ /* search_background: ${configs.search_background = `rgba( 0, 0, 0,${configs.opacity / 2})`} */ /* border_color: ${configs.border_color = `rgba( 0, 0, 0,${configs.opacity})`} */ /* activeButton_color: ${configs.activeButton_color = `rgba( 81,195, 0,1)`} */ /* progressbar_zIndex: ${configs.progressbar_zIndex = 110} */ /* panel_zIndex: ${configs.panel_zIndex = 100} */ /* channelPane_zIndex: ${configs.channelPane_zIndex = 11} */ /* scrollers_zIndex: ${configs.scrollers_zIndex = 10} */ /* button_zIndex: ${configs.button_zIndex = 10} */ /* search_zIndex: ${configs.search_zIndex = 10} */ /* program_zIndex: ${configs.program_zIndex = 1} */ /* nav_transition: ${configs.nav_transition = '500ms cubic-bezier(.17,.84,.44,1)'} (Quartic) */ /* アベマ公式の不要要素 */ /* (レイアウトを崩す謎要素に、とりあえず穏便に表示位置の調整で対応する) */ .pub_300x250, .pub_300x250m, .pub_728x90, .text-ad, .textAd, .text_ad, .text_ads, .text-ads, .text-ad-links, #announcer, dummy{ position: absolute; bottom: 0; } /* マーク共通 */ .mark, .mark > *{ width: 1em !important; } .mark.bingeWatching, .mark.recommendation{ width: ${5/3}em !important; } .mark.none{ width: 2em !important; height: auto !important; } .mark{ fill: white; margin: 0 .2em 0 0; } span.mark{ vertical-align: middle; position: relative; display: inline-block; } .mark > svg{ vertical-align: middle; position: absolute; left: 0; top: 0; } .mark.newcomer > svg:nth-child(1), .mark.live > svg:nth-child(1){ fill: #f0163a; } .mark.last{ margin-right: 0; margin-left: .2em; } /* 通知その他ボタン共通 */ button.myvideo, button.repeat_all, button.play, button.notify{ padding: 5px;/*クリッカブル領域を広げる*/ margin: -5px; box-sizing: content-box; position: relative;/*個別調整用*/ z-index: ${configs.button_zIndex}; pointer-events: auto; transition: transform 250ms ease-in; } button.myvideo > *, button.repeat_all > *, button.play > *, button.notify > *{ fill: white; width: auto; border-radius: 50vmax; overflow: visible;/*目覚まし時計アイコンのベル部分*/ transform: scaleX(1); pointer-events: none; } button.repeat_all > *{ position: relative; bottom: .1em !important;/*微調整*/ } button.notify.once > *{ fill: ${configs.activeButton_color}; background: white; padding: 0; border: .05em solid white; box-sizing: border-box; overflow: hidden;/*目覚まし時計アイコンのベル部分*/ } button.notify.repeat > *{ fill: white; background: ${configs.activeButton_color}; padding: .05em 0 0 .05em; border: .1em solid white; box-sizing: border-box; overflow: visible; } button.notify.search > *{ fill: white; background: ${configs.activeButton_color}; padding: .1em; border: .1em solid white; box-sizing: border-box; overflow: visible; } button.myvideo:hover, button.repeat_all:hover, button.play:hover, button.notify:hover{ filter: brightness(.5); } button.myvideo.reversing, button.repeat_all.reversing, button.play.reversing, button.notify.reversing{ transform: scaleX(0); transition: transform 250ms ease-out; } button.repeat_all:not(.active) > *{ transform: scaleX(-1); } button.myvideo.active > *, button.repeat_all.active > *, button.play.current > *{ fill: ${configs.activeButton_color}; filter: brightness(1.25);/*視認性を高める*/ } button.myvideo use, button.notify use{ display: none; } button.myvideo:not(.active) use.plus, button.myvideo.active use.checked, button.notify:not(.once):not(.repeat):not(.search) use.plus, button.notify.once:not(.repeat):not(.search) use.checked, button.notify.repeat:not(.search) use.repeat, button.notify.search use.search{ display: inline; } /* アベマ公式 裏番組一覧の表示非表示 */ html.channelPaneHidden [data-selector="channelPane"]{ opacity: 0;/*translateXでは読み込みが発生しない*/ z-index: -1; transition: opacity 500ms ease 500ms;/*チラ見えさせない努力*/ } html.channelPaneHidden [data-selector="screen"] > div[style]{ width: 100% !important; height: 100% !important; } /* アベマ公式 裏番組一覧の改変 */ /* (アベマ公式に上書きされがちなので独自セレクタは使いにくい) */ [data-selector="channelPane"]{ width: 25vw; min-width: 40vh; } [data-selector="channelPane"] > div{ min-height: 100%; display: flex; flex-direction: column; } [data-selector="channelPane"] > div > a{ height: ${configs.channelPane_roweight}vh; border-left: none !important;/*現在チャンネルに付く公式のボーダーをなくす*/ padding: 0; width: 100%; overflow: hidden; } [data-selector="channelPane"] > div > a ~ a{ border-top: 1px solid ${configs.border_color} !important;/*公式のボーダーを置き換える*/ } [data-selector="channelPane"] > div > a[data-hidden="true"]{ display: none; } [data-selector="channelPane"] > div > a > div{ position: relative; } [data-selector="channelPane"] > div > a > div > div:nth-child(1)/*サムネイル*/{ border-right: 1px solid ${configs.border_color}; background: ${configs.nowOnAir_background}; padding: ${configs.channelPane_padding}vh; box-sizing: content-box; } [data-selector="channelPane"] > div > a > div > div:nth-child(1)/*サムネイル*/ > div > div{ height: ${configs.channelPane_thumbheight}vh !important; width: ${configs.channelPane_thumbheight * (16/9)}vh !important; } [data-selector="channelPane"] > div > a > div > div:nth-child(1)/*サムネイル*/ > div > div > img{ min-height: 100%; min-width: 100%; } [data-selector="channelPane"] > div > a > div > div:nth-child(1)/*サムネイル*/ > div > div + img/*チャンネル名*/{ width: ${configs.channelPane_thumbheight * (16/9)}vh; height: auto; } [data-selector="channelPane"] > div > a > div > div ~ div/*番組共通*/, [data-selector="channelPane"] > div > a:last-child/*番組表リンク*/{ border-right: 1px solid ${configs.border_color}; background: ${configs.comming_background}; padding: ${configs.channelPane_padding}vh 0 !important;/*公式の左パディングを打ち消す*/ overflow: hidden; min-width: 0;/*中身が長くても伸ばさずすぐあふれさせる*/ position: absolute; } [data-selector="channelPane"] > div > a > div > div ~ div/*番組共通*/{ clip-path: inset(0 -100vw 0 0);/*overflowさせるのは右方向だけ*/ background-clip: padding-box !important;/*border-leftの色を保証*/ height: 100%; } [data-selector="channelPane"] > div > a > div > div ~ div/*番組共通*/.transition/*ハイライトを付与する際のトランジション*/{ transition: background 500ms ease; } [data-selector="channelPane"] > div > a > div > div:nth-child(2)/*放送中の番組*/{ background: ${configs.nowOnAir_background}; } [data-selector="channelPane"] > div > a > div > div ~ div > div/*タイトルと放送時間*/{ margin-left: ${configs.channelPane_padding}vh; } [data-selector="channelPane"] > div > a > div > div ~ div > div/*タイトルと放送時間*/, [data-selector="channelPane"] > div > a > div > div ~ div > div/*タイトルと放送時間*/ *{ font-weight: normal !important;;/*公式の現在チャンネルの太字を打ち消す*/ font-size: ${configs.channelPane_fontsize}vh; line-height: ${configs.channelPane_lineheight}vh; margin-bottom: 0;/*公式の下マージンを打ち消す*/ white-space: nowrap; } [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(1)/*タイトル*/ > span, [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(2)/*放送時間*/{ display: flex; align-items: center; } [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(1)/*タイトル*/ > span > span[style], [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(1)/*タイトル*/ > span > span[style] > *, [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(1)/*タイトル*/ > span > svg[width], [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(1)/*タイトル*/ > span > .mark, [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(1)/*タイトル*/ > span > .mark *{ font-size: ${configs.channelPane_fontsize}vh; height: ${configs.channelPane_fontsize}vh !important; width: 1em !important; min-width: 1em !important;/*なぜかこれを指定しないとレイアウトが崩れる要素が発生する*/ } [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(1)/*タイトル*/ > span > svg[width^="23"]{ width: ${5/3}em !important;/*ちょっとトリッキーだが…*/ min-width: ${5/3}em !important; } [data-selector="channelPane"] > div > a > div > div ~ div:not(:hover) > div:nth-child(2)/*放送時間*/ *{ color: ${configs.transparentGray}; } [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(2)/*放送時間*/ > button/*通知ボタン*/, [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(2)/*放送時間*/ > button/*通知ボタン*/ *{ height: ${configs.channelPane_lineheight}vh; } [data-selector="channelPane"] > div > a > div > div ~ div > div:nth-child(2)/*放送時間*/ > button/*通知ボタン*/{ padding: 0; margin: 0 ${configs.channelPane_padding}vh 0 calc(-${configs.channelPane_padding}vh - ${configs.channelPane_lineheight}vh - 1px/*端数対応*/); transition: margin 500ms ease, transform 250ms ease-in;; pointer-events: auto !important; } [data-selector="channelPane"] > div > a > div > div ~ div:hover > div:nth-child(2)/*放送時間*/ > button/*通知ボタン*/{ margin: 0 .2em 0 0; } [data-selector="channelPane"] > div > a[data-current="true"] > div > div:nth-child(1)/*サムネイル*/, [data-selector="channelPane"] > div > a[data-current="true"] > div > div:nth-child(1) + div/*放送中の番組*/, [data-selector="channelPane"] > div > a > div > div:nth-child(1) ~ div.active/*通知番組*/{ background: ${configs.current_background} !important; } [data-selector="channelPane"] > div > a[data-current="true"] > div > div:nth-child(1) + div > */*放送中の番組*/, [data-selector="channelPane"] > div > a > div > div:nth-child(1) ~ div.active > */*通知番組*/{ filter: brightness(100%) !important;/*nocontentの指定を上書き*/ } [data-selector="channelPane"] > div > a[data-current="true"] > div > div:nth-child(1) + div */*放送中の番組の中身*/, [data-selector="channelPane"] > div > a > div > div:nth-child(1) ~ div.active */*通知番組の中身*/{ color: white !important; } [data-selector="channelPane"] > div > a:hover{ opacity: 1;/*公式の不透明度をなくす*/ } [data-selector="channelPane"] > div > a:hover > div > div:nth-child(1)/*サムネイル*/, [data-selector="channelPane"] > div > a:hover > div > div:nth-child(1)/*サムネイル*/ ~ div/*番組*/{ background: ${configs.hover_background}; } [data-selector="channelPane"] > div > a > div > div:nth-child(1):hover/*サムネイル*/ + div/*放送中の番組*/, [data-selector="channelPane"] > div > a > div > div:nth-child(1)/*サムネイル*/ ~ div:hover/*番組*/{ overflow: visible; z-index: ${configs.program_zIndex}; } [data-selector="channelPane"] > div > a > div > div:nth-child(1):hover/*サムネイル*/ + div */*放送中の番組の中身*/, [data-selector="channelPane"] > div > a > div > div:nth-child(1)/*サムネイル*/ ~ div:hover */*番組の中身*/{ color: white !important; pointer-events: none;/*overflowしていても後続番組にhoverをゆずる*/ } [data-selector="channelPane"] > div > a:hover > div > div:nth-child(1):not(:hover)/*サムネイル*/ + div:not(:hover)/*放送中の番組*/, [data-selector="channelPane"] > div > a:hover > div > div:nth-child(1)/*サムネイル*/ + div ~ div:not(:hover)/*後続番組*/{ filter: brightness(.5); } [data-selector="channelPane"] > div > a > div > div:nth-child(1):hover/*サムネイル*/ + div ~ div > */*後続番組の中身*/, [data-selector="channelPane"] > div > a > div > div:nth-child(1)/*サムネイル*/ ~ div:hover/*番組*/ ~ div > */*後続番組の中身*/{ opacity: .25; } [data-selector="channelPane"] > div > a:not(:hover) > div > div:nth-child(1)/*サムネイル*/ ~ div.nocontent{ background: ${configs.noContent_background}; } [data-selector="channelPane"] > div > a:not(:hover) > div > div:nth-child(1)/*サムネイル*/ ~ div.nocontent > *{ filter: brightness(.25); } [data-selector="channelPane"] > div > a:last-child/*番組表リンク*/{ font-size: ${configs.channelPane_fontsize}vh; line-height: ${configs.channelPane_roweight * .4}vh;/*端数ズレが起きるため理論値の.5に対して余裕を持たせる*/ padding: 0 !important; position: relative; flex: 1; } [data-selector="channelPane"] > div > a:last-child:hover/*番組表リンク*/{ background: rgba(128,128,128,.5); } [data-selector="channelPane"] > div > a:last-child/*番組表リンク*/ > svg{ height: ${configs.channelPane_fontsize}vh; } /* アベマ公式 番組表の置き換え */ html.abemaTimetable #splash > div{ display: block;/*公式のnoneを上書き*/ } html.abemaTimetable main *{/*負荷の低減を試みる*/ transition: none !important; animation: none !important; pointer-events: none !important; } html.abemaTimetable [data-selector="progressbar"]{ display: none; } /* アベマ公式 プログレスバー */ [data-selector="progressbar"]{ z-index: ${configs.progressbar_zIndex}; } /* パネル共通 */ #${SCRIPTNAME}-panels{ position: absolute; width: 100%; height: 100%; top: 0; left: 0; overflow: hidden; pointer-events: none; } #${SCRIPTNAME}-panels div.panel{ position: absolute; max-height: 100%;/*小さなウィンドウに対応*/ overflow: auto; left: 50%; bottom: 50%; transform: translate(-50%, 50%); z-index: ${configs.panel_zIndex}; background: rgba(0,0,0,.75); transition: ${configs.nav_transition}; padding: 5px 0; pointer-events: auto; } #${SCRIPTNAME}-panels div.panel.hidden{ bottom: 0; transform: translate(-50%, 100%); } #${SCRIPTNAME}-panels h1, #${SCRIPTNAME}-panels h2, #${SCRIPTNAME}-panels h3, #${SCRIPTNAME}-panels h4, #${SCRIPTNAME}-panels legend, #${SCRIPTNAME}-panels li, #${SCRIPTNAME}-panels dt, #${SCRIPTNAME}-panels dd, #${SCRIPTNAME}-panels code, #${SCRIPTNAME}-panels p{ color: rgba(255,255,255,1); font-size: 14px; padding: 2px 10px; line-height:20px; } #${SCRIPTNAME}-panels header{ display: flex; } #${SCRIPTNAME}-panels header h1{ flex: 1; } #${SCRIPTNAME}-panels > div.panel > p.buttons{ text-align: right; padding: 5px 10px; } #${SCRIPTNAME}-panels > div.panel > p.buttons button{ width: 120px; padding: 5px 10px; margin-left: 10px; border-radius: 5px; color: rgba(255,255,255,1); background: rgba(64,64,64,1); border: 1px solid rgba(255,255,255,1); } #${SCRIPTNAME}-panels > div.panel > p.buttons button.primary{ font-weight: bold; background: rgba(0,0,0,1); } #${SCRIPTNAME}-panels > div.panel > p.buttons button:hover, #${SCRIPTNAME}-panels > div.panel > p.buttons button:focus{ background: rgba(128,128,128,.75); } #${SCRIPTNAME}-panels .template{ display: none !important; } /* 番組表パネル */ #${SCRIPTNAME}-timetable-panel{ background: rgba(0,0,0,${configs.opacity}) !important; width: 100% !important; height: 100% !important; padding: 0 !important; overflow: hidden !important; /*display: grid;*//*Chrome Gridバグ回避*/ grid-template-columns: auto; grid-template-rows: 1fr auto ${configs.height}vh; } #${SCRIPTNAME}-timetable-panel > header > h1{ display: none; } #${SCRIPTNAME}-timetable-panel > header > p.buttons{ padding: 5px 10px; position: fixed; top: 0; right: 0; z-index: ${configs.panel_zIndex}; } #${SCRIPTNAME}-timetable-panel button.config{ fill: white; filter: drop-shadow(0 0 2.5px rgba(0,0,0,.75)); padding: 5px; margin: -5px; height: 30px; } #${SCRIPTNAME}-timetable-panel button.config:hover{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel > .program{ grid-column: 1; grid-row: 1; height: calc(100vh - ${configs.rowheight * 1.4}vh - ${configs.height}vh);/*Chrome Gridバグ回避*/ } #${SCRIPTNAME}-timetable-panel > nav{ grid-column: 1; grid-row: 2; position: absolute;/*Chrome Gridバグ回避*/ bottom: ${configs.height}vh;/*Chrome Gridバグ回避*/ } #${SCRIPTNAME}-timetable-panel > .programs{ grid-column: 1; grid-row: 3; overflow: hidden; position: absolute !important;/*Chrome Gridバグ回避*/ bottom: -${configs.scrollbarWidth}px;/*Chrome Gridバグ回避*/ width: 100vw;/*Chrome Gridバグ回避*/ } #${SCRIPTNAME}-timetable-panel > p.buttons:last-of-type{ position: absolute; bottom: 0; right: 0; z-index: ${configs.panel_zIndex}; } #${SCRIPTNAME}-timetable-panel h1, #${SCRIPTNAME}-timetable-panel h2, #${SCRIPTNAME}-timetable-panel h3, #${SCRIPTNAME}-timetable-panel h4, #${SCRIPTNAME}-timetable-panel legend, #${SCRIPTNAME}-timetable-panel li, #${SCRIPTNAME}-timetable-panel dt, #${SCRIPTNAME}-timetable-panel dd, #${SCRIPTNAME}-timetable-panel code, #${SCRIPTNAME}-timetable-panel p{ padding: .1em .5em; } /* 番組情報 */ #${SCRIPTNAME}-timetable-panel > .program{ word-wrap: break-word; margin-right: -${configs.scrollbarWidth}px;/*スクロールバーを隠す*/ -webkit-mask-image: linear-gradient(black 90%, rgba(0,0,0,.5));/*まだ-webkit取れない*/ mask-image: linear-gradient(black 90%, rgba(0,0,0,.5)); position: relative; overflow-x: hidden; overflow-y: scroll; display: grid; grid-template-columns: 2fr 2fr 2fr 1fr 1fr; grid-template-rows: ${configs.lineheight * 1.5}vh auto ${configs.lineheight * .825}vh; transition: opacity 500ms ease; } #${SCRIPTNAME}-timetable-panel > .program > .thumbnails, #${SCRIPTNAME}-timetable-panel > .program > .summary, #${SCRIPTNAME}-timetable-panel > .program > .content{ max-width: 25vw;/*max指定しておけばword-break-allしなくてすむ*/ } #${SCRIPTNAME}-timetable-panel > .program > .casts, #${SCRIPTNAME}-timetable-panel > .program > .crews{ max-width: 12.5vw; } #${SCRIPTNAME}-timetable-panel > .program *{ font-size: ${configs.fontsize}vh; line-height: ${configs.lineheight}vh; } #${SCRIPTNAME}-timetable-panel > .program a{ color: ${configs.link_color}; text-decoration: none; filter: brightness(1.25);/*視認性を高める*/ } #${SCRIPTNAME}-timetable-panel > .program a:hover{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel > .program.nocontent{ opacity: .25; } /* 番組情報 タイトル */ #${SCRIPTNAME}-timetable-panel > .program > h2{ white-space: nowrap; grid-column: 2 / 6; grid-row: 1; } #${SCRIPTNAME}-timetable-panel > .program > h2 *{ font-size: ${configs.fontsize * 1.5}vh; line-height: ${configs.lineheight * 1.5}vh; vertical-align: middle; } #${SCRIPTNAME}-timetable-panel > .program > h2 > .mark, #${SCRIPTNAME}-timetable-panel > .program > h2 > .mark *{ height: ${configs.fontsize * 1.5}vh !important; } /* 番組情報 サムネイル */ #${SCRIPTNAME}-timetable-panel > .program > .thumbnails{ grid-column: 1; grid-row: 1 / 4; } #${SCRIPTNAME}-timetable-panel > .program > .thumbnails img:first-child{ width: calc(100% - 2vh); } #${SCRIPTNAME}-timetable-panel > .program > .thumbnails img{ width: calc(50% - 1.5vh); margin: 1vh 0 0 1vh; transition: opacity 500ms ease; } #${SCRIPTNAME}-timetable-panel > .program > .thumbnails img.loading{ opacity: 0; } /* 番組情報 サマリ */ #${SCRIPTNAME}-timetable-panel > .program > .summary{ grid-column: 2; grid-row: 2 / 4; } #${SCRIPTNAME}-timetable-panel > .program > .summary .inactive{ display: none; } #${SCRIPTNAME}-timetable-panel > .program > .summary h3 > *{ vertical-align: middle; } #${SCRIPTNAME}-timetable-panel > .program > .summary button, #${SCRIPTNAME}-timetable-panel > .program > .summary button > *{ width: calc(${configs.fontsize}vh + .2em);/*限界まで膨れさせる*/ height: calc(${configs.fontsize}vh + .2em); bottom: -.2em; } #${SCRIPTNAME}-timetable-panel > .program > .summary button.repeat_all, #${SCRIPTNAME}-timetable-panel > .program > .summary button.repeat_all > *{ width: calc(${configs.fontsize}vh + .4em);/*限界まで膨れさせる*/ height: calc(${configs.fontsize}vh + .4em); bottom: 0em; } #${SCRIPTNAME}-timetable-panel > .program > .summary button + *{ margin-left: .25em; } #${SCRIPTNAME}-timetable-panel > .program > .summary button + .date + *{ margin-left: 1em; } #${SCRIPTNAME}-timetable-panel > .program > .summary li header{ background: ${configs.listed_background}; border-radius: calc(${configs.lineheight / 2}vh); padding: .1em calc(${configs.fontsize / 2}vh - .1em) .1em 0; display: inline; cursor: pointer; } #${SCRIPTNAME}-timetable-panel > .program > .summary li header .mark, #${SCRIPTNAME}-timetable-panel > .program > .summary li header .mark *{ height: ${configs.fontsize}vh; vertical-align: text-bottom; } #${SCRIPTNAME}-timetable-panel > .program > .summary li header:hover, #${SCRIPTNAME}-timetable-panel > .program > .summary li.current header{ color: ${configs.transparentGray}; background: ${configs.listed_backgroundHover}; } #${SCRIPTNAME}-timetable-panel > .program > .summary li header:hover .mark, #${SCRIPTNAME}-timetable-panel > .program > .summary li.current header .mark{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel > .program > .summary li.current header{ cursor: auto; } #${SCRIPTNAME}-timetable-panel > .program > .summary li header *{ vertical-align: baseline;/*headerが既にinline要素なので*/ } /* 番組情報 番組概要 */ #${SCRIPTNAME}-timetable-panel > .program > .content{ grid-column: 3; grid-row: 2 / 4; } /* 番組情報 キャスト・スタッフ */ #${SCRIPTNAME}-timetable-panel > .program > .casts{ grid-column: 4; grid-row: 2 / 3; } #${SCRIPTNAME}-timetable-panel > .program > .crews{ grid-column: 5; grid-row: 2 / 3; } #${SCRIPTNAME}-timetable-panel > .program > .casts .name, #${SCRIPTNAME}-timetable-panel > .program > .crews .name{ color: black; background: white; padding: 1px calc(${configs.fontsize / 2}vh - .2em); border-radius: calc(${configs.lineheight / 2}vh); margin: 0 1px; cursor: pointer; } #${SCRIPTNAME}-timetable-panel > .program > .casts .name:hover, #${SCRIPTNAME}-timetable-panel > .program > .crews .name:hover{ filter: brightness(.5); } /* 番組情報 コピーライト */ #${SCRIPTNAME}-timetable-panel > .program > .copyrights{ font-size: ${configs.fontsize * .825}vh; line-height: ${configs.lineheight * .825}vh; text-align: right; padding: 0 1vh; grid-column: 3 / 6; grid-row: 3; } /* 番組表ナビゲーション */ #${SCRIPTNAME}-timetable-panel > nav{ display: flex; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift{ flex: 1; } #${SCRIPTNAME}-timetable-panel > nav > .search{ width: ${100*(1/3)}vw; } /* 番組表ナビゲーション 日付・時間 */ #${SCRIPTNAME}-timetable-panel > nav > .timeshift{ display: flex; align-items: center; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift .days{ width: calc((${100*(2/3)}vw - ${NAMEWIDTH}vw)/2 + ${NAMEWIDTH}vw - 2vh); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift .times{ width: calc((${100*(2/3)}vw - ${NAMEWIDTH}vw)/2); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times{ font-size: ${configs.rowfontsize}vh; line-height: ${configs.rowheight}vh; height: ${configs.rowheight}vh; padding: 0; margin: .2em 0 .2em 1vh; border-radius: .5em; overflow: hidden; display: flex; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days input, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times input{ display: none; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times label{ color: white; background: rgba(112,112,112,.25); text-align: center; white-space: nowrap; width: 100%; margin-left: 1px; padding: 0 1px; min-width: 1em; overflow: hidden; flex: 1; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label:first-of-type{ min-width: calc(${NAMEWIDTH}vw - 1vh - 1px); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label:first-of-type, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times label:first-of-type{ margin-left: 0; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days input:not(:checked) + label, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times input:not(:checked) + label{ cursor: pointer; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days input:checked + label, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label:hover, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label:focus, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times input:checked + label, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times label:hover, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times label:focus{ background: rgba(112,112,112,.75); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label.sat{ background: rgba(112,160,192,.25); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label.sun{ background: rgba(192,112,112,.25); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days input:checked + label.sat, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label.sat:hover, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label.sat:focus{ background: rgba(112,160,192,.75); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days input:checked + label.sun, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label.sun:hover, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label.sun:focus{ background: rgba(192,112,112,.75); } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times input:disabled + label{ color: black; opacity: .25; cursor: auto; } #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .days label > .fit, #${SCRIPTNAME}-timetable-panel > nav > .timeshift > .times label > .fit{ display: block;/*以下、チャンネル名幅調整用*/ transform-origin: left; transition: transform 500ms ease; } /* 番組表ナビゲーション 検索 */ #${SCRIPTNAME}-timetable-panel > nav > .search{ font-size: ${configs.rowfontsize}vh; line-height: ${configs.rowheight}vh; padding: 0; display: flex; align-items: center; } #${SCRIPTNAME}-timetable-panel > nav > .search > input[type="search"]{ border: 1px solid transparent;/*ブラウザデフォルトスタイルの解消も兼ねる*/ border-radius: .2em 0 0 .2em; height: ${configs.rowheight}vh; box-sizing: content-box; width: 100%; min-width: 0;/*幅が足りなければ素直に縮ませる*/ padding: 0 0 0 .5em; margin: .2em 0 .2em 1vh; } #${SCRIPTNAME}-timetable-panel > nav > .search > button.search{ background: rgb(192,192,192); border: 1px solid transparent; border-radius: 0 .2em .2em 0; flex-shrink: 0; height: ${configs.rowheight}vh; box-sizing: content-box; padding: 0 .5em; margin: .2em 1vh .2em 0; } #${SCRIPTNAME}-timetable-panel > nav > .search > button.search:hover{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel > nav > .search > button.search > svg{ width: ${configs.rowfontsize}vh; height: ${configs.rowfontsize}vh; fill: white; vertical-align: middle; } /* 番組表ナビゲーション 通知 */ #${SCRIPTNAME}-timetable-panel > nav > .search > button.notifications{ font-size: ${configs.rowfontsize}vh; white-space: nowrap; margin-right: ${(configs.height < 90) ? '1vh' : 'calc(1vh + 30px)'};/*設定ボタンにかぶらないように*/ display: flex; align-items: center; } #${SCRIPTNAME}-timetable-panel > nav > .search > button.notifications:hover{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel > nav > .search > button.notifications > *{ flex-shrink: 0; } #${SCRIPTNAME}-timetable-panel > nav > .search > button.notifications svg{ fill: ${configs.activeButton_color}; filter: brightness(1.25);/*視認性を高める*/ width: ${configs.rowheight}vh; height: ${configs.rowheight}vh; margin-right: .2em; } #${SCRIPTNAME}-timetable-panel > nav > .search > button.notifications[data-count="0"] svg{ fill: ${configs.transparentGray}; filter: brightness(1); } /* 番組表 */ #${SCRIPTNAME}-timetable-panel > .programs{ position: relative; } #${SCRIPTNAME}-timetable-panel .channels{ position: relative; left: ${NAMEWIDTH}vw; width: ${100 - NAMEWIDTH}vw; padding: 0; overflow-y: hidden; transition: width 500ms ease;/*searchPaneの開閉用*/ } #${SCRIPTNAME}-timetable-panel .search.active ~ .channels{ width: calc(${100*(2/3) - NAMEWIDTH}vw - 1px); } #${SCRIPTNAME}-timetable-panel .channels *{ color: white; font-size: ${configs.rowfontsize}vh; line-height: calc(${configs.rowheight}vh - 1px);/*borderぶん*/ white-space: nowrap; } #${SCRIPTNAME}-timetable-panel .channels > li{ height: ${configs.rowheight}vh; padding: 0; position: relative; } #${SCRIPTNAME}-timetable-panel .channels > li.channel{ overflow: hidden; } #${SCRIPTNAME}-timetable-panel .channels > li > header{ padding: 0; border-top: 1px solid ${configs.border_color}; border-right: 1px solid ${configs.border_color}; text-align: center; position: fixed; left: 0; width: ${NAMEWIDTH}vw; overflow: hidden;/*これを指定しないとFirefoxでposition:fixedが狂うバグあり*/ cursor: pointer; transition: transform 500ms ease;/*初回左右からの登場用*/ } #${SCRIPTNAME}-timetable-panel .channels > li.channel > header{ background: ${configs.nowOnAir_background}; background-clip: padding-box !important; } #${SCRIPTNAME}-timetable-panel .channels > li.channel.notonair > header{ cursor: auto;/*放送してないチャンネルはクリッカブルにしない*/ } #${SCRIPTNAME}-timetable-panel .channels > li > header > .name{ width: 100%; padding: 0; text-align: center; transform-origin: left;/*以下、チャンネル名幅調整用*/ transition: transform 500ms ease; } #${SCRIPTNAME}-timetable-panel .channels > li > .stream{ width: 100%; border-top: 1px solid ${configs.border_color}; position: relative; transition: transform 500ms ease;/*初回左右からの登場用(疑似スクロール処理時はjsで上書きする)*/ } #${SCRIPTNAME}-timetable-panel .channels > li.animate, #${SCRIPTNAME}-timetable-panel .channels > li.animate *{ pointer-events: none !important;/*position:fixedバグの回避*/ } #${SCRIPTNAME}-timetable-panel .channels > li.animate > header, #${SCRIPTNAME}-timetable-panel .channels > li.animate > .stream{ will-change: transform;/*position:fixedが狂うバグが発生するのでGrid時はコメントアウト*/ } #${SCRIPTNAME}-timetable-panel .channels > li.hidden > header{ transform: translateX(-${NAMEWIDTH}vw);/*これもposition:fixedが狂うバグに関与している*/ } #${SCRIPTNAME}-timetable-panel .channels > li.hidden > .stream{ transform: translateX(${100 - NAMEWIDTH}vw); } /* 番組表 時刻・個別番組共通 */ #${SCRIPTNAME}-timetable-panel .channels .slot{ padding: 0; border-right: 1px solid ${configs.border_color}; position: absolute; overflow: hidden; display: flex; align-items: center;/*.markを中央揃え*/ cursor: pointer; transition: opacity 250ms ease;/*出現時(1分シフト時はjsで上書きする)*/ } #${SCRIPTNAME}-timetable-panel .channels .slot.transition/*ハイライトを付与する際専用のトランジション*/{ transition: background 500ms ease; } #${SCRIPTNAME}-timetable-panel .channels .slot > *{ flex-shrink: 0; pointer-events: none;/*e.targetをli.programに統一 & overflowしていても後続番組にhoverをゆずる*/ } #${SCRIPTNAME}-timetable-panel .channels .hour > *:nth-child(1)/*時刻*/, #${SCRIPTNAME}-timetable-panel .channels .program > *:nth-child(2)/*(通知ボタンの次の)時刻*/, #${SCRIPTNAME}-timetable-panel .channels .program > *:nth-child(3)/*タイトルまたはmark*/{ margin-left: .25em; } #${SCRIPTNAME}-timetable-panel .channels > .time .hour:not(.nowonair) .time, #${SCRIPTNAME}-timetable-panel .channels > .channel:not(:hover) .program:not(.active):not(.shown) .time{ color: ${configs.transparentGray};/*区切りとしての役割も果たす*/ } /* 番組表 時刻列 */ #${SCRIPTNAME}-timetable-panel .channels > .time > header > button.now{ background: ${configs.nowOnAir_background}; text-align: right !important; width: 100%; padding-right: .25em; overflow: hidden; display: block; transition: opacity 500ms ease; } #${SCRIPTNAME}-timetable-panel .channels > .time > header > button.now:hover, #${SCRIPTNAME}-timetable-panel .channels .hour:hover{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel .channels > .time > header > button.now .arrows{ display: inline-block; transition: transform 500ms ease; } #${SCRIPTNAME}-timetable-panel .channels > .time > header > button.now.disabled{ opacity: .5; } #${SCRIPTNAME}-timetable-panel .channels > .time > header > button.now.disabled .arrows{ transform: translateX(1.25em); pointer-events: none; } #${SCRIPTNAME}-timetable-panel .channels .times .hour:nth-child(2)/*clock*/{ padding-left: 1px; } #${SCRIPTNAME}-timetable-panel .channels .times .hour .clock .blink{ animation: blink 2s step-end infinite; } @keyframes blink{ 50%{opacity: .5} } #${SCRIPTNAME}-timetable-panel .channels .day{ border-right: 1px solid ${configs.border_color}; height: ${configs.height}vh; position: absolute; overflow: hidden; cursor: auto; } #${SCRIPTNAME}-timetable-panel .channels .day .date{ color: rgba(255,255,255,.125); font-weight: bold; font-size: ${configs.height}vh; line-height: ${configs.height}vh; } #${SCRIPTNAME}-timetable-panel .channels .hour{ background: ${configs.times_background}; } /* 番組表 個別番組 */ #${SCRIPTNAME}-timetable-panel .channels .program.hidden{ opacity: 0; } #${SCRIPTNAME}-timetable-panel .channels .program{ background: ${configs.comming_background}; } #${SCRIPTNAME}-timetable-panel .channels .program > button, #${SCRIPTNAME}-timetable-panel .channels .program > button *{ height: calc(${configs.rowheight}vh - 1px);/*borderぶん*/ } #${SCRIPTNAME}-timetable-panel .channels .program > button{ padding: 0; margin: 0 0 0 calc(-${configs.rowheight}vh + 1px); opacity: 0;/*端数ピクセルがチラ見えしてしまうことがあるので*/ transition: margin 500ms ease, transform 250ms ease-in; pointer-events: auto; } #${SCRIPTNAME}-timetable-panel .channels .program.shown > button{ margin-left: .25em; opacity: 1; } #${SCRIPTNAME}-timetable-panel .channels .program > .mark, #${SCRIPTNAME}-timetable-panel .channels .program > .mark *{ height: ${configs.fontsize}vh; } #${SCRIPTNAME}-timetable-panel .channels .program.nowonair{ background: ${configs.nowOnAir_background}; padding-left: ${BOUNCINGPIXEL}px; } #${SCRIPTNAME}-timetable-panel .channels .program.nowonair > button{ display: none; } #${SCRIPTNAME}-timetable-panel .channels .program > .time{ transition: max-width 1000ms ease, margin-left 1000ms ease; max-width: 3em; overflow: hidden; } #${SCRIPTNAME}-timetable-panel .channels .program.nowonair > .time{ max-width: 0; margin-left: 0; } #${SCRIPTNAME}-timetable-panel .channels .program.shown/*番組情報表示中の番組*/, #${SCRIPTNAME}-timetable-panel .channels .channel:hover header, #${SCRIPTNAME}-timetable-panel .channels .channel:hover .program{ background: ${configs.hover_background}; } #${SCRIPTNAME}-timetable-panel .channels header:hover + .stream .program.nowonair, #${SCRIPTNAME}-timetable-panel .channels .program:hover{ overflow: visible; clip-path: inset(0 -100vw 0 0);/*overflowさせるのは右方向だけ*/ z-index: ${configs.program_zIndex}; } #${SCRIPTNAME}-timetable-panel .channels .channel:hover header:not(:hover), #${SCRIPTNAME}-timetable-panel .channels .channel:hover header:not(:hover) + .stream .program.nowonair:not(:hover), #${SCRIPTNAME}-timetable-panel .channels .channel:hover .program:not(:hover):not(.nowonair)/*後続番組*/{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel .channels header:hover + .stream .program:not(.nowonair) > */*後続番組の中身*/, #${SCRIPTNAME}-timetable-panel .channels .channel:hover .program:not(:hover):not(.nowonair) > */*後続番組の中身*/{ opacity: .25; } html:not(.abemaTimetable) #${SCRIPTNAME}-timetable-panel .channels .channel.current header, html:not(.abemaTimetable) #${SCRIPTNAME}-timetable-panel .channels .channel.current .program.nowonair, #${SCRIPTNAME}-timetable-panel .channels .program.active{ background: ${configs.current_background} !important; } #${SCRIPTNAME}-timetable-panel .channels .channel:not(:hover) .program.nocontent{ background: ${configs.noContent_background}; } #${SCRIPTNAME}-timetable-panel .channels .channel:not(:hover) .program.nocontent .title{ filter: brightness(.25); } #${SCRIPTNAME}-timetable-panel .channels .channel .program.padding/*空き枠*/{ cursor: auto; } /* 番組表スクローラ */ #${SCRIPTNAME}-timetable-panel .scrollers{ font-size: ${configs.fontsize}vh;/*emサイズ指定用*/ position: absolute; bottom: 0; left: ${NAMEWIDTH}vw; width: ${100 - NAMEWIDTH}vw; height: 100%; z-index: ${configs.scrollers_zIndex}; pointer-events: none; } #${SCRIPTNAME}-timetable-panel .scrollers button.disabled{ pointer-events: none; opacity: 0; } #${SCRIPTNAME}-timetable-panel .scrollers button{ background: ${configs.scroller_background}; border-radius: 5em; width: 5em; height: 5em; transform: translateY(50%); position: absolute; bottom: 50%; opacity: .25; transition: opacity 500ms ease, right 500ms ease; pointer-events: auto; } #${SCRIPTNAME}-timetable-panel .scrollers button:hover{ opacity: 1; } #${SCRIPTNAME}-timetable-panel .scrollers button.left{ left: .5em; } #${SCRIPTNAME}-timetable-panel .scrollers button.right{ right: .5em; } #${SCRIPTNAME}-timetable-panel .search.active ~ .scrollers button.right{ right: calc(${100*(1/3)}vw + .5em); opacity: 1; } #${SCRIPTNAME}-timetable-panel .scrollers button > *{ width: 2em; height: 2em; vertical-align: middle; opacity: .5; } /* 番組検索結果 */ #${SCRIPTNAME}-timetable-panel > .programs > .search{ background: ${configs.search_background}; border-top: 1px solid ${configs.border_color}; border-left: 1px solid ${configs.border_color}; width: calc(${100*(1/3)}vw + 1px + ${configs.scrollbarWidth}px); height: 100%; box-sizing: border-box; margin-right: -${configs.scrollbarWidth}px;/*スクロールバーを隠す*/ -webkit-mask-image: linear-gradient(black 90%, rgba(0,0,0,.5));/*まだ-webkit取れない*/ mask-image: linear-gradient(black 90%, rgba(0,0,0,.5)); overflow-x: hidden; overflow-y: scroll; position: absolute; top: 0; right: 0; z-index: ${configs.search_zIndex}; transform: translateX(100%); transition: transform 500ms ease; } #${SCRIPTNAME}-timetable-panel > .programs > .search.active, #${SCRIPTNAME}-timetable-panel > .programs > .search:hover{ transform: translateX(0); } #${SCRIPTNAME}-timetable-panel > .programs > .search *{ font-size: ${configs.search_fontsize}vh; line-height: ${configs.search_lineheight}vh; } #${SCRIPTNAME}-timetable-panel > .programs > .search .mark, #${SCRIPTNAME}-timetable-panel > .programs > .search .mark *{ height: ${configs.search_fontsize}vh; line-height: ${configs.search_fontsize}vh; } /* 番組検索結果 ヘッダ */ #${SCRIPTNAME}-timetable-panel > .programs > .search header{ display: block; } /* 番組検索結果 フィルタ */ #${SCRIPTNAME}-timetable-panel > .programs > .search .filters{ width: calc(100% - 2vh); padding: 0; margin: .25em 1vh; border: 1px solid transparent;/*検索欄とツラ合わせしやすく*/ height: calc(1.92vh + .5em); border-radius: .5em; overflow: hidden; display: flex; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input{ display: none; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters label::before{ content: '✓'; color: black; font-size: ${configs.search_lineheight}vh; left: .1em; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input:checked + label::before{ color: white; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input + label{ color: ${configs.transparentGray};/*:not:checked*/ filter: brightness(.25);/*:not:checked*/ background: rgba(96,96,96,.75); white-space: nowrap; position: relative; margin-left: 1px; overflow: hidden; flex: 1; display: flex; align-items: center;/*.markを中央揃え*/ cursor: pointer; transition: background 500ms ease; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input:checked + label{ color: white; filter: brightness(1); } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input + label:hover{ filter: brightness(.5); } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input:checked + label:hover{ filter: brightness(.75); } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input + label.notify{ background: ${configs.activeButton_color}; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input + label > *{ flex-shrink: 0; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input + label > .mark, #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input + label > .mark *{ font-size: ${(configs.search_fontsize + configs.search_lineheight) / 2}vh; height: ${(configs.search_fontsize + configs.search_lineheight) / 2}vh; } #${SCRIPTNAME}-timetable-panel > .programs > .search .filters input + label:first-of-type{ margin-left: 0; } /* 番組検索結果 通知種別 */ #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs{ margin: .25em 0; display: flex; } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input{ display: none; } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input + label{ color: rgb(128,128,128); padding: .25em 1vh; border-bottom: 1px solid rgb(64,64,64); flex: 1; display: flex; align-items: center; } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input:not(:checked) + label:hover{ color: rgb(192,192,192); } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input:checked + label{ color: rgb(256,256,256); border: 1px solid rgb(64,64,64); border-bottom: none; } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input:checked + label:first-of-type{ border-left: none; } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input:checked + label:last-of-type{ border-right: none; } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input + label > svg{ fill: rgb(128,128,128); height: ${(configs.search_fontsize + configs.search_lineheight) / 2}vh; margin-right: .2em; flex-shrink: 0; } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input:not(:checked) + label:hover > svg{ fill: rgb(192,192,192); } #${SCRIPTNAME}-timetable-panel > .programs > .search .tabs > input:checked + label > svg{ fill: rgb(256,256,256); } /* 番組検索結果 サマリ(件数・検索通知) */ #${SCRIPTNAME}-timetable-panel > .programs > .search .summary{ padding: 0; margin: .5em 1vh; display: flex; align-items: center; } #${SCRIPTNAME}-timetable-panel > .programs > .search .summary > *{ white-space: nowrap; } #${SCRIPTNAME}-timetable-panel > .programs > .search .summary .count{ flex: 1; } #${SCRIPTNAME}-timetable-panel > .programs > .search button.search_all{ text-align: left; background: rgba(96,96,96,.75); border: .1em solid transparent; border-radius: 50vmax; padding: .15em calc(${configs.search_fontsize / 2}vh - 1px); margin: 0; flex-shrink: 0; display: flex; align-items: center;/*.markを中央揃え*/ transition: transform 250ms ease-in; } #${SCRIPTNAME}-timetable-panel > .programs > .search button.search_all:hover{ background: rgba(96,96,96,.25); filter: brightness(1);/*打ち消し*/ } #${SCRIPTNAME}-timetable-panel > .programs > .search button.search_all.reversing{ transform: scaleY(0); transition: transform 250ms ease-out; } #${SCRIPTNAME}-timetable-panel > .programs > .search button.search_all.active{ background: ${configs.activeButton_color}; border: .1em solid white; } #${SCRIPTNAME}-timetable-panel > .programs > .search button.search_all > *{ margin-right: .25em; transform: scaleX(1); flex-shrink: 0; } #${SCRIPTNAME}-timetable-panel > .programs > .search button.search_all > svg:first-child/*検索アイコン*/{ fill: white; width: calc(${configs.search_fontsize}vh + .25em);/*膨れさせる*/ height: calc(${configs.search_fontsize}vh + .25em);/*膨れさせる*/ } #${SCRIPTNAME}-timetable-panel > .programs > .search button.search_all .mark{ margin-left: .125em; margin-right: .125em; } /* 番組検索結果 番組リスト */ #${SCRIPTNAME}-timetable-panel > .programs > .search ul{ padding: 0; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program{ height: calc(${configs.search_fontsize + configs.search_lineheight}vh);/*この高さがh2,間隙,.dataの高さになる*/ padding: 0; margin: .5vh 1vh 1vh 1vh; display: grid; grid-template-columns: calc(${configs.search_lineheight * 2 * (16/9)}vh) 1fr; grid-template-rows: ${configs.search_lineheight}vh ${configs.search_lineheight}vh; height: ${configs.search_lineheight * 2}vh; cursor: pointer; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program:hover{ filter: brightness(.75); } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .thumbnail{ width: calc(${configs.search_lineheight * 2 * (16/9)}vh); height: calc(${configs.search_lineheight * 2}vh); padding: 0; grid-column: 1; grid-row: 1 / 2; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .thumbnail img{ display: block; width: auto;/*4:3もある*/ max-width: calc(${configs.search_lineheight * 2 * (16/9)}vh - 1px);/*端数処理ではみ出すのを防ぐ*/ height: calc(${configs.search_lineheight * 2}vh); margin: 0 auto; transition: opacity 500ms ease; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .thumbnail img.loading{ opacity: 0; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > h2, #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .data{ white-space: nowrap; padding: 0 1vh; display: flex; align-items: center;/*.markを中央揃え*/ } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > h2 > *, #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .data > *{ flex-shrink: 0; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > h2{ height: ${(configs.search_lineheight + configs.search_fontsize) / 2}vh;/*ほどよく切り詰める*/ grid-column: 2; grid-row: 1; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > h2 .mark, #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > h2 .mark *{ height: ${configs.search_fontsize}vh; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > h2 .title{ vertical-align: middle; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .data{ color: ${configs.transparentGray}; vertical-align: middle; grid-column: 2; grid-row: 2; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .data button, #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .data button > *{ font-size: ${configs.fontsize}vh;/*emサイズを合わせる*/ height: ${configs.search_lineheight}vh; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .data button + *{ margin-left: .25em; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.program > .data button + * ~ *{ margin-left: 1em; } /* 番組検索結果 番組リスト(日付別・毎回通知・検索通知共通) */ #${SCRIPTNAME}-timetable-panel > .programs > .search li.day, #${SCRIPTNAME}-timetable-panel > .programs > .search li.repeat, #${SCRIPTNAME}-timetable-panel > .programs > .search li.search{ padding: 0; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.day > h2, #${SCRIPTNAME}-timetable-panel > .programs > .search li.repeat > h2, #${SCRIPTNAME}-timetable-panel > .programs > .search li.search > h2{ padding-left: 1vh; white-space: nowrap; display: flex; align-items: center; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.repeat > h2 button + *, #${SCRIPTNAME}-timetable-panel > .programs > .search li.search > h2 button + *{ margin-left: .25em; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.noprogram{ color: gray; padding-left: 1vh; } /* 番組検索結果 番組リスト(毎回通知) */ #${SCRIPTNAME}-timetable-panel > .programs > .search li.repeat > h2 button, #${SCRIPTNAME}-timetable-panel > .programs > .search li.repeat > h2 button > *{ height: ${configs.search_fontsize}vh; } /* 番組検索結果 番組リスト(検索通知) */ #${SCRIPTNAME}-timetable-panel > .programs > .search li.search > h2 button, #${SCRIPTNAME}-timetable-panel > .programs > .search li.search > h2 button > *{ height: ${configs.search_lineheight}vh; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.search > h2 button > *{ fill: ${configs.activeButton_color}; background: transparent; border: none; filter: brightness(1.25); } #${SCRIPTNAME}-timetable-panel > .programs > .search li.search > h2 .key{ display: flex; align-items: center; } #${SCRIPTNAME}-timetable-panel > .programs > .search li.search > h2 .key .mark{ margin-left: .125em; margin-right: .125em; } /* 設定パネル */ #${SCRIPTNAME}-config-panel{ width: 360px; } #${SCRIPTNAME}-config-panel fieldset p, #${SCRIPTNAME}-config-panel fieldset li{ padding-left: calc(10px + 1em); } #${SCRIPTNAME}-config-panel fieldset .sub{ padding-left: calc(10px + 2em); } #${SCRIPTNAME}-config-panel fieldset p:hover, #${SCRIPTNAME}-config-panel fieldset li:hover{ background: rgba(255,255,255,.25); } #${SCRIPTNAME}-config-panel fieldset p.disabled, #${SCRIPTNAME}-config-panel fieldset li.disabled{ opacity: .5; } #${SCRIPTNAME}-config-panel label{ display: block; } #${SCRIPTNAME}-config-panel input{ width: 80px; height: 20px; position: absolute; right: 10px; } #${SCRIPTNAME}-config-panel fieldset ul.channels{ columns: 2; column-gap: 0; } #${SCRIPTNAME}-config-panel fieldset ul.channels li input{ width: 20px; vertical-align: bottom; margin-right: .25em; position: static; } </style> `, }, }; if(!('animate' in HTMLElement.prototype)) HTMLElement.prototype.animate = function(){}; if(!('isConnected' in Node.prototype)) Node.prototype.isConnected = true; class Storage{ static key(key){ return (SCRIPTNAME) ? (SCRIPTNAME + '-' + key) : key; } static save(key, value, expire = null){ key = Storage.key(key); localStorage[key] = JSON.stringify({ expire: expire, value: value, }); } static read(key){ key = Storage.key(key); if(localStorage[key] === undefined) return undefined; let data = JSON.parse(localStorage[key]); if(data.value === undefined) return data; if(data.expire === undefined) return data; if(data.expire === null) return data.value; if(data.expire < Date.now()) return localStorage.removeItem(key); return data.value; } static delete(key){ key = Storage.key(key); delete localStorage[key]; } } let $ = function(s){return document.querySelector(s)}; let $$ = function(s){return document.querySelectorAll(s)}; let animate = function(callback, ...params){requestAnimationFrame(() => requestAnimationFrame(() => callback(...params)))}; let sequence = function(){ let chain = [], defer = function(callback, delay, ...params){(delay) ? setTimeout(callback, delay, ...params) : animate(callback, ...params)}; for(let i = arguments.length - 1, delay = 0; 0 <= i; i--, delay = 0){ if(typeof arguments[i] === 'function'){ for(let j = i - 1; typeof arguments[j] === 'number'; j--) delay += arguments[j]; let f = arguments[i], d = delay, callback = chain[chain.length - 1]; chain.push(function(pass){defer(function(ch){ch ? ch(f(pass)) : f(pass);}, d, callback)});/*nearly black magic*/ } } chain[chain.length - 1](); }; let observe = function(element, callback, options = {childList: true, attributes: false, characterData: false}){ let observer = new MutationObserver(callback.bind(element)); observer.observe(element, options); return observer; }; let createElement = function(html){ let outer = document.createElement('div'); outer.innerHTML = html; return outer.firstElementChild; }; let getScrollbarWidth = function(){ let div = document.createElement('div'); div.textContent = 'dummy'; document.body.appendChild(div); div.style.overflowY = 'scroll'; let clientWidth = div.clientWidth; div.style.overflowY = 'hidden'; let offsetWidth = div.offsetWidth; document.body.removeChild(div); return offsetWidth - clientWidth; }; let normalize = function(string){ return string.trim().replace(/[!-}]/g, function(s){ return String.fromCharCode(s.charCodeAt(0) - 0xFEE0); }).replace(/ /g, ' ').replace(/~/g, '〜'); }; let linkify = function(node){ split(node); function split(n){ if(['style', 'script', 'a'].includes(n.localName)) return; if(n.nodeType === Node.TEXT_NODE){ let pos = n.data.search(linkify.RE); if(0 <= pos){ let target = n.splitText(pos);/*pos直前までのnとpos以降のtargetに分割*/ let rest = target.splitText(RegExp.lastMatch.length);/*targetと続くrestに分割*/ /* この時点でn(処理済み),target(リンクテキスト),rest(次に処理)の3つに分割されている */ let a = document.createElement('a'); let match = target.data.match(linkify.RE); switch(true){ case(match[1] !== undefined): a.href = (match[1][0] == 'h') ? match[1] : 'h' + match[1]; break; case(match[2] !== undefined): a.href = 'http://' + match[2]; break; case(match[3] !== undefined): a.href = 'mailto:' + match[4] + '@' + match[5]; break; } a.appendChild(target);/*textContent*/ rest.parentNode.insertBefore(a, rest); } }else{ for(let i = 0; n.childNodes[i]; i++) split(n.childNodes[i]);/*回しながらchildNodesは増えていく*/ } } }; linkify.RE = new RegExp([ '(h?ttps?://[-\\w_./~*%$@:;,!?&=+#]+[-\\w_/~*%$@:;&=+#])',/*通常のURL*/ '((?:\\w+\\.)+\\w+/[-\\w_./~*%$@:;,!?&=+#]*)',/*http://の省略形*/ '((\\w[-\\w_.]+)(?:@|@)(\\w[-\\w_.]+\\w))',/*メールアドレス*/ ].join('|')); let log = function(){ if(!DEBUG) return; let l = log.last = log.now || new Date(), n = log.now = new Date(); let stack = new Error().stack, callers = stack.match(/^([^/<]+(?=<?@))/gm) || stack.match(/[^. ]+(?= \(<anonymous)/gm) || []; console.log( SCRIPTNAME + ':', /* 00:00:00.000 */ n.toLocaleTimeString() + '.' + n.getTime().toString().slice(-3), /* +0.000s */ '+' + ((n-l)/1000).toFixed(3) + 's', /* :00 */ ':' + stack.match(/:[0-9]+:[0-9]+/g)[1].split(':')[1],/*LINE*/ /* caller.caller */ (callers[2] ? callers[2] + '() => ' : '') + /* caller */ (callers[1] || '') + '()', ...arguments ); }; core.initialize(); if(window === top && console.timeEnd) console.timeEnd(SCRIPTNAME); })(); |