From 0f5e0a3957759907ceaea340ba5c7792c93c07e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Wed, 23 Jun 2021 15:12:01 +0200 Subject: [PATCH] Enable for homepage Specifically, Anime of the Fortnight and Album of the Week --- .../display_anime_names.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/animebytes_display_anime_names/display_anime_names.js b/animebytes_display_anime_names/display_anime_names.js index 9a50db2..9507d5c 100644 --- a/animebytes_display_anime_names/display_anime_names.js +++ b/animebytes_display_anime_names/display_anime_names.js @@ -1,15 +1,25 @@ // ==UserScript== -// @name Display anime names in collages +// @name Display anime names under pictures // @namespace Violentmonkey Scripts // @match https://animebytes.tv/collage.php +// @match https://animebytes.tv/ // @grant none // @version 1.1 // @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 // ==/UserScript== -let r = document.querySelectorAll('#collage_table tbody tr td') -r.forEach((element) => { +let url_selectors = { + "^(https?://)?animebytes.tv/?$": ".aot_inner", + "^(https?://)?animebytes.tv/collage.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;'