Last active
April 15, 2023 11:37
-
-
Save BoberMod/12170a2d265f4431c06ca3ff6d13ff6f to your computer and use it in GitHub Desktop.
Shows the date of the last currently released episode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Shikimori: last currently released episode | |
// @name:ru Шикимори: дата последнего вышедшего эпизода | |
// @namespace https://shikimori.one | |
// @version 0.3 | |
// @description Shows the date of the last currently released episode | |
// @description:ru Показывает дату последней на данный момент вышедшей серии | |
// @author BoberMod | |
// @match https://shikimori.org/animes/* | |
// @match https://shikimori.one/animes/* | |
// @match https://shikimori.me/animes/* | |
// @downloadURL https://gist.github.com/BoberMod/12170a2d265f4431c06ca3ff6d13ff6f/raw/last-episode-date.user.js | |
// @updateURL https://gist.github.com/BoberMod/12170a2d265f4431c06ca3ff6d13ff6f/raw/last-episode-date.user.js | |
// @grant none | |
// ==/UserScript== | |
function showDate() { | |
"use strict"; | |
if (!document.querySelector('.b-anime_status_tag')?.classList.contains("ongoing")) return; | |
const lastEpisodeDateSelector = document.querySelector(".b-menu-links.menu-topics-block.history .b-menu-line .time time"); | |
const nextEpisode = document.querySelectorAll(".b-entry-info .line-container")[2]; | |
//const lastEpisodeDate = lastEpisodeDateSelector.innerText; | |
const newInfoLine = createNewInfoLine("Последний эпизод: ", lastEpisodeDateSelector.cloneNode(true)); | |
nextEpisode.insertAdjacentElement('beforebegin', newInfoLine); | |
} | |
function createNewInfoLine(key, value) { | |
let lineContainer = document.createElement('div'); | |
lineContainer.setAttribute("class", "line-container"); | |
let lineElement = document.createElement('div'); | |
lineElement.setAttribute("class", "line"); | |
lineContainer.append(lineElement); | |
let keyElement = document.createElement('div'); | |
keyElement.setAttribute("class", "key"); | |
keyElement.innerText = key; | |
lineElement.append(keyElement); | |
let valueElement = value; | |
valueElement.setAttribute("class", "value"); | |
lineElement.append(valueElement); | |
return lineContainer; | |
} | |
function onload(fn) { | |
document.addEventListener('page:load', fn); | |
document.addEventListener('turbolinks:load', fn); | |
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") { | |
fn(); | |
} else { | |
document.addEventListener('DOMContentLoaded', fn); | |
} | |
} | |
onload(showDate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment