ServusTV Adblocker

Blocks Banner, Preroll & Midroll Ads on ServusTV.com

  1. // ==UserScript==
  2. // @name ServusTV Adblocker
  3. // @name:de ServusTV Werbeblocker
  4. // @version 1.0.2
  5. // @description Blocks Banner, Preroll & Midroll Ads on ServusTV.com
  6. // @description:de Blockiert Banner, Preroll & Midroll Werbungen auf ServusTV.com
  7. // @icon https://external-content.duckduckgo.com/ip3/www.servustv.com.ico
  8. // @author TalkLounge (https://github.com/TalkLounge)
  9. // @namespace https://github.com/TalkLounge/servustv-adblocker
  10. // @license MIT
  11. // @match https://www.servustv.com/*
  12. // @match https://www.m3u8player.online/embed/*
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17. let lastURL;
  18.  
  19. async function init() {
  20. [...document.querySelectorAll(".ad-wrap, [id^=adslot]")].forEach(item => item.parentNode?.remove());
  21.  
  22. if (lastURL == window.location.pathname) {
  23. return;
  24. }
  25.  
  26. lastURL = window.location.pathname;
  27.  
  28. const url = window.location.pathname.split("/").filter(item => item).reverse();
  29. if (url[1] != "v") {
  30. return;
  31. }
  32.  
  33. while (true) {
  34. if (document.querySelector(".theatre-mode>div>picture") && document.querySelector(".theatre-mode>div>div + div div")) {
  35. break;
  36. }
  37.  
  38. await new Promise(r => setTimeout(r, 100));
  39. }
  40.  
  41. document.querySelector(".theatre-mode>div>picture").style.display = "none";
  42. document.querySelector(".theatre-mode>div>div").style.display = "none";
  43.  
  44. document.querySelector(".theatre-mode>div>div + div div").style.display = "none";
  45. document.querySelector(".theatre-mode>div>div + div rbup-video-stv")?.remove();
  46. document.querySelector(".theatre-mode>div>div + div iframe")?.remove();
  47.  
  48. let data = await fetch(`https://api-player.redbull.com/stv/servus-tv-playnet?videoId=${url[0].toUpperCase()}`, {
  49. "method": "GET",
  50. "referrer": "https://www.servustv.com/"
  51. });
  52. data = await data.json();
  53.  
  54. const iframe = document.createElement("iframe");
  55. iframe.src = `https://www.m3u8player.online/embed/m3u8?url=${encodeURIComponent(data.videoUrl)}`;
  56. iframe.width = "100%";
  57. iframe.height = "100%";
  58. iframe.style.border = "none";
  59. iframe.style.aspectRatio = "16/9";
  60. iframe.allowFullscreen = true;
  61.  
  62. document.querySelector(".theatre-mode>div>div + div").append(iframe);
  63. }
  64.  
  65. async function deleteCookieBanner() {
  66. for (let i = 0; i < 4 * 10; i++) {
  67. if (document.querySelector(".fixed")) {
  68. document.querySelector(".fixed").remove();
  69. break;
  70. }
  71.  
  72. await new Promise(r => setTimeout(r, 250));
  73. }
  74. }
  75.  
  76. if (window.location.href.startsWith("https://www.servustv.com/") && window.top == window.self) { // Main Page
  77. window.setInterval(init, 250);
  78. } else if (window.location.href.startsWith("https://www.m3u8player.online/embed/m3u8") && window.top != window.self) { // Iframe
  79. deleteCookieBanner();
  80. }
  81. })();