Setnmh helper

Improve setnmh

  1. // ==UserScript==
  2. // @name Setnmh helper
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Improve setnmh
  6. // @author You
  7. // @match https://www.setnmh.com/series-*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=setnmh.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. var iframe;
  17. var loading;
  18.  
  19. const container = document.querySelector('.ptview');
  20.  
  21. function processImage(image) {
  22. console.log('processImage', image);
  23.  
  24. const img = document.createElement('img');
  25. img.src = image;
  26. container.appendChild(img);
  27.  
  28. console.log(img);
  29. }
  30.  
  31. function processPage(page) {
  32. console.log('processPage', page);
  33.  
  34. if (!iframe) {
  35. iframe = document.createElement('iframe');
  36. iframe.style.position = 'absolute';
  37. iframe.style.width = '0px';
  38. iframe.style.height = '0px';
  39. document.body.appendChild(iframe);
  40. }
  41. iframe.src = page;
  42.  
  43. showLoading(page);
  44. }
  45.  
  46. function showLoading(page) {
  47. if (!loading) {
  48. loading = document.createElement('div');
  49. loading.style.textAlign = 'center';
  50. loading.style.position = 'fixed';
  51. loading.style.left = '50%';
  52. loading.style.top = '0px';
  53. loading.style.transform = 'translateX(-50%)';
  54. loading.style.zIndex = 999999;
  55. loading.style.color = '#000';
  56. loading.style.background = 'rgba(255, 255, 255, .8)';
  57. loading.padding = '2px';
  58. document.body.appendChild(loading);
  59. }
  60. loading.textContent = `Loading ${page}`;
  61. }
  62.  
  63. function hideLoading() {
  64. if (loading) {
  65. loading.remove();
  66. loading = undefined;
  67. }
  68. }
  69.  
  70. const nextPageA = document.querySelector('.setnmh-next.mhicon.icon-jiantou-right');
  71. if (window.parent != window.top) {
  72. const interval = setInterval(() => {
  73. const img = document.querySelector('.setnmh-seebox img');
  74. if (!img) return;
  75.  
  76. clearInterval(interval);
  77. window.top.postMessage({ nextPagePath: nextPageA?.href, image: img.src }, location.origin);
  78. }, 100);
  79. return;
  80. }
  81.  
  82. window.addEventListener('message', e => {
  83. if (e.data.image) {
  84. processImage(event.data.image);
  85. }
  86. if (e.data.nextPagePath) {
  87. processPage(e.data.nextPagePath);
  88. } else {
  89. hideLoading();
  90. }
  91. });
  92.  
  93. if (nextPageA) processPage(nextPageA.href);
  94. })();

QingJ © 2025

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