userscripts/animebytes_display_anime_names/display_anime_names.js

31 lines
1.4 KiB
JavaScript

// ==UserScript==
// @name Display anime names under pictures
// @namespace Violentmonkey Scripts
// @match https://animebytes.tv/collage.php
// @match https://animebytes.tv/company.php
// @match https://animebytes.tv/
// @grant none
// @version 1.4
// @author Lukáš Kucharczyk
// @description Displays anime titles underneath posters on the collage page.
// @downloadURL https://git.kucharczyk.xyz/lukas/userscripts/raw/branch/main/animebytes_display_anime_names/display_anime_names.js
// @updateURL https://git.kucharczyk.xyz/lukas/userscripts/raw/branch/main/animebytes_display_anime_names/display_anime_names.js
// @supportURL https://git.kucharczyk.xyz/lukas/userscripts
// ==/UserScript==
let url_selectors = {
"^(https?://)?animebytes.tv/?$": ".aot_inner",
"^(https?://)?animebytes.tv/(collage|company).php": "#collage_table tbody tr td"
}
let selectors_as_array = Object.entries(url_selectors)
let selector = selectors_as_array.filter(([key, value]) => {
let regex = new RegExp(key)
return regex.test(window.location)
})
let elements = document.querySelectorAll(selector[0][1])
elements.forEach((element) => {
let anime_title = element.querySelector('a img').attributes['alt'].value
let anime_title_div = document.createElement('div')
anime_title_div.style = 'width: 125px; height: 50px;'
element.appendChild(anime_title_div)
anime_title_div.innerText = anime_title
})