BetterAnimeWorld

Migliora AnimeWorld

安装此脚本?
作者推荐脚本

您可能也喜欢AnimeWorld Skipper

安装此脚本
  1. // ==UserScript==
  2. // @name BetterAnimeWorld
  3. // @namespace https://pizidavi.altervista.org/
  4. // @icon https://static.animeworld.so/assets/images/favicon/android-icon-192x192.png
  5. // @description Migliora AnimeWorld
  6. // @author pizidavi
  7. // @version 1.8.3
  8. // @copyright 2023, PIZIDAVI
  9. // @license MIT
  10. // @require https://cdn.jsdelivr.net/gh/soufianesakhi/node-creation-observer-js@edabdee1caaee6af701333a527a0afd95240aa3b/release/node-creation-observer-latest.min.js
  11. // @require https://gf.qytechs.cn/scripts/453212-faviconbadger/code/FaviconBadger.js
  12. // @match https://www.animeworld.ac/*
  13. // @grant GM_addStyle
  14. // @grant GM_openInTab
  15. // @grant GM_xmlhttpRequest
  16. // @grant window.onurlchange
  17. // @run-at document-body
  18. // ==/UserScript==
  19.  
  20. /* global NodeCreationObserver, Notify */
  21.  
  22. (function() {
  23. 'use strict';
  24.  
  25. const PAGE_TITLE = document.title;
  26. const PAGE_ANIME_TITLE = '{{title}} Ep. {{episode}} - AnimeWorld';
  27. const PAGE_ANIME_TITLE_NO_EP = '{{title}} - AnimeWorld';
  28.  
  29. const ANIMEWORLD_SKIPPER_URL = 'https://gf.qytechs.cn/it/scripts/472503-animeworld-skipper';
  30.  
  31. const faviconBadger = new FaviconBadger({
  32. size: 0.63
  33. });
  34.  
  35. NodeCreationObserver.onCreation('#sign > div.signed ul', function (element) {
  36. addStyle('#header .head #sign .signed, #header .head #sign .signin { width: unset !important; } #tagsReload { max-height: 50px !important;}');
  37.  
  38. element.querySelector('li:nth-child(3) > a').href += '?folder=1&sort=2';
  39. element.querySelector('li:nth-child(4) > a').textContent = 'Notifiche';
  40. element.querySelector('li:nth-child(4) > a').href = '/notifications';
  41. });
  42.  
  43. NodeCreationObserver.onCreation('#notification', function (element) {
  44. getNotify();
  45. setInterval(function() {
  46. getNotify();
  47. }, 2*60*1000); // 2 minuti
  48.  
  49. if (location.pathname.includes('/play/'))
  50. window.addEventListener('urlchange', (info) => {
  51. setNotify();
  52. });
  53. });
  54.  
  55. NodeCreationObserver.onCreation('div.menu-profile', function (element) {
  56. element.querySelector('a.pulsante-profilo-tabs:nth-child(2)').href += '?folder=1&sort=2';
  57. if(location.pathname.includes('/watchlist'))
  58. document.querySelector('.cover-profilo-aw').style.display = 'none';
  59. });
  60.  
  61. if(location.pathname.includes('/play/')) {
  62. NodeCreationObserver.onCreation('#player .cover, div.server ul a, #controls > div.prevnext', function (element) {
  63. element.addEventListener('click', function() {
  64. window.scrollTo(0, 133);
  65. const r = document.querySelector('#controls .resize');
  66. if(r.textContent.includes('Espandi'))
  67. r.click();
  68.  
  69. setTimeout(function() {
  70. document.querySelector('#controls .light').click();
  71. document.cookie = 'expandedPlayer=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
  72. }, 700);
  73. });
  74. });
  75.  
  76. NodeCreationObserver.onCreation('#player iframe', function (element) {
  77. if (document.querySelector('[name="AnimeWorldSkipper"]') !== null) return;
  78.  
  79. const button = document.createElement('button');
  80. button.id = 'skip-intro-ads';
  81. button.textContent = 'Salta Intro';
  82. button.style = 'position: absolute; bottom: 6em; right: 2em; padding: 0.5em 1em 0.4em; font-size: 14px; border: 1px solid #bdc3c7; border-radius: 2px; color: #bdc3c7; background-color: rgba(0,0,0,0.7); opacity: 0.25; z-index:2147483648;';
  83.  
  84. element.addEventListener('load', function(e) {
  85. if (!this.contentDocument) return;
  86. const video = this.contentDocument?.querySelector('video');
  87. if (!video) return;
  88. button.onclick = function(e) {
  89. e.preventDefault(); e.stopPropagation();
  90. if (typeof GM_openInTab !== 'undefined')
  91. GM_openInTab(ANIMEWORLD_SKIPPER_URL, false);
  92. else
  93. window.open(ANIMEWORLD_SKIPPER_URL);
  94. };
  95. video.parentNode.append(button);
  96. });
  97. });
  98. }
  99. else if(location.pathname.includes('/notifications')) {
  100. NodeCreationObserver.onCreation('#delete-all', function (element) {
  101. const parentDiv = element.parentElement;
  102. const button = element.cloneNode();
  103. button.id = 'delete-read-all';
  104. button.innerHTML = '<i class="fas fa-trash"></i> Cancella tutte le notifiche "lette"';
  105. button.onclick = function() {
  106. Swal.fire({
  107. title: 'Vuoi davvero cancellare tutte le notifiche lette?',
  108. icon: 'question',
  109. showCancelButton: true,
  110. confirmButtonColor: 'rgb(165, 220, 134)',
  111. cancelButtonColor: 'rgb(221, 51, 51)',
  112. confirmButtonText: 'Si',
  113. cancelButtonText: 'No',
  114. }).then((result) => {
  115. if (result.value) {
  116. document.querySelectorAll('.profile-page .row .widget:nth-child(2) li.is-notification-read').forEach(function(e, i) {
  117. e.querySelector('.actions i.delete-clickable-icon').click();
  118. });
  119. }
  120. });
  121. };
  122. parentDiv.appendChild(button);
  123. element.remove();
  124. });
  125. }
  126.  
  127.  
  128. // ------- Function -------
  129. function getNotify() {
  130. request({
  131. url: '/request-serie',
  132. success: function(data) {
  133. const html = document.createElement('html'); html.innerHTML = data;
  134. document.querySelector('#notification > ul').innerHTML = html.querySelector('#notification > ul').innerHTML;
  135. setNotify();
  136.  
  137. document.querySelectorAll('#notification > ul > li[data-id]').forEach(function(li, index) {
  138. const span = li.querySelector('.header-notification-read');
  139. span.addEventListener('click', function(e) {
  140. e.preventDefault(); e.stopPropagation();
  141. request({
  142. url: '/api/notifications/open/'+li.getAttribute('data-id'),
  143. success: function(data) {
  144. li.remove();
  145. setNotify();
  146. }
  147. });
  148. });
  149. });
  150. }
  151. });
  152. }
  153.  
  154. function setNotify() {
  155. const number = document.querySelectorAll('ul.notification > li[data-id]').length || '0';
  156. document.querySelectorAll('.notifications-number').forEach((value, index) => {
  157. value.textContent = number;
  158. });
  159.  
  160. faviconBadger.value = number;
  161. faviconBadger.update();
  162.  
  163. if(location.pathname.includes('/play/')) {
  164. const title = document.querySelector('#anime-title').textContent;
  165. const episode = document.querySelector('div.server ul a.active')?.getAttribute('data-base');
  166. if (episode && episode !== '1')
  167. document.title = PAGE_ANIME_TITLE.replace('{{title}}', title).replace('{{episode}}', episode);
  168. else
  169. document.title = PAGE_ANIME_TITLE_NO_EP.replace('{{title}}', title);
  170. }
  171. else
  172. document.title = PAGE_TITLE;
  173. }
  174.  
  175. function request(options) {
  176. const onreadystatechange = function() {
  177. if (this.readyState === 4 && (this.status == 200 || this.status == 201)) {
  178. options.success(this.responseText);
  179. } else if (this.readyState === 4) {
  180. console.warn('%cBetterAnimeWorld%c - Errore nella richiesta', 'color:red;font-size:14px;', '');
  181. }
  182. };
  183. if (typeof GM_xmlhttpRequest != 'undefined') {
  184. options.onload = onreadystatechange;
  185. GM_xmlhttpRequest(options);
  186. } else {
  187. const xhttp = new XMLHttpRequest();
  188. xhttp.open(options.method || 'GET', options.url);
  189. xhttp.onreadystatechange = onreadystatechange;
  190. xhttp.send();
  191. }
  192. }
  193.  
  194. function addStyle(CSS) {
  195. if (typeof GM_addStyle != 'undefined') {
  196. GM_addStyle(CSS);
  197. } else {
  198. const style = document.createElement('style');
  199. style.innerText = CSS;
  200. document.head.appendChild(style);
  201. }
  202. }
  203.  
  204. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址