Senpa+

Automatically close the Continue window and remove ads from Senpa.io

目前为 2024-06-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Senpa+
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description Automatically close the Continue window and remove ads from Senpa.io
  6. // @author ChatGPT
  7. // @match https://senpa.io/web/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to simulate the pressing of the "Esc" key
  15. function triggerEscKey() {
  16. var event = new KeyboardEvent('keydown', {
  17. bubbles: true,
  18. cancelable: true,
  19. keyCode: 27,
  20. key: 'Escape',
  21. code: 'Escape'
  22. });
  23. document.dispatchEvent(event);
  24. }
  25.  
  26. // Function to detect the respawn window and trigger the "Esc" key
  27. function checkRespawnWindow() {
  28. var respawnWindow = document.querySelector('.modal.scale-modal');
  29. if (respawnWindow && getComputedStyle(respawnWindow).opacity === '1') {
  30. console.log('Respawn window detected, triggering Esc key...');
  31. setTimeout(triggerEscKey, 10);
  32. }
  33. }
  34.  
  35. // Function to remove ads and social sidebar
  36. function removeAdsAndSocialSidebar() {
  37. // Remove div with id "bottomAd"
  38. var bottomAdDiv = document.getElementById("bottomAd");
  39. if (bottomAdDiv) {
  40. bottomAdDiv.parentNode.removeChild(bottomAdDiv);
  41. }
  42.  
  43. // Remove divs with class "ads-block-1"
  44. var adsBlockDivs = document.querySelectorAll(".ads-block-1");
  45. adsBlockDivs.forEach(function(adsBlockDiv) {
  46. adsBlockDiv.parentNode.removeChild(adsBlockDiv);
  47. });
  48.  
  49. // Remove divs with class "banner"
  50. var bannerDivs = document.querySelectorAll(".banner");
  51. bannerDivs.forEach(function(bannerDiv) {
  52. bannerDiv.parentNode.removeChild(bannerDiv);
  53. });
  54.  
  55. // Remove divs with class "advertisement-informer-endgame"
  56. var advertisementInformerEndgameDivs = document.querySelectorAll(".advertisement-informer-endgame");
  57. advertisementInformerEndgameDivs.forEach(function(advertisementInformerEndgameDiv) {
  58. advertisementInformerEndgameDiv.parentNode.removeChild(advertisementInformerEndgameDiv);
  59. });
  60.  
  61. // Remove div with id "senpa-io_300x250_3"
  62. var senpaIoDiv = document.getElementById("senpa-io_300x250_3");
  63. if (senpaIoDiv) {
  64. senpaIoDiv.parentNode.removeChild(senpaIoDiv);
  65. }
  66.  
  67. // Remove ul with id "socialsidebar"
  68. var socialSidebarUl = document.getElementById("socialsidebar");
  69. if (socialSidebarUl) {
  70. socialSidebarUl.parentNode.removeChild(socialSidebarUl);
  71. }
  72. }
  73.  
  74. // Check for the respawn window periodically
  75. setInterval(checkRespawnWindow, 150);
  76.  
  77. // Wait for the DOM to be fully loaded and then remove ads and social sidebar
  78. window.addEventListener('load', removeAdsAndSocialSidebar);
  79.  
  80. // Observe DOM mutations to remove ads and social sidebar dynamically
  81. var observer = new MutationObserver(function(mutations) {
  82. mutations.forEach(function(mutation) {
  83. if (mutation.addedNodes.length) {
  84. removeAdsAndSocialSidebar();
  85. }
  86. });
  87. });
  88.  
  89. observer.observe(document.body, { childList: true, subtree: true });
  90.  
  91. })();