Setnmh helper

Improve setnmh

  1. // ==UserScript==
  2. // @name Setnmh helper
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  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. const img = document.createElement('img');
  23. img.src = image;
  24. container.appendChild(img);
  25.  
  26. console.log(img);
  27. }
  28.  
  29. function processPage(page) {
  30. if (!iframe) {
  31. iframe = document.createElement('iframe');
  32. iframe.style.position = 'absolute';
  33. iframe.style.width = '0px';
  34. iframe.style.height = '0px';
  35. document.body.appendChild(iframe);
  36. }
  37. iframe.src = page;
  38.  
  39. showLoading(page);
  40. }
  41.  
  42. function showLoading(page) {
  43. if (!loading) {
  44. loading = document.createElement('div');
  45. loading.style.textAlign = 'center';
  46. loading.style.position = 'fixed';
  47. loading.style.left = '50%';
  48. loading.style.top = '0px';
  49. loading.style.transform = 'translateX(-50%)';
  50. loading.style.zIndex = 999999;
  51. loading.style.color = '#000';
  52. loading.style.background = 'rgba(255, 255, 255, .8)';
  53. loading.style.padding = '2px 5px';
  54. document.body.appendChild(loading);
  55. }
  56. loading.textContent = `Loading ${page}`;
  57. }
  58.  
  59. function hideLoading() {
  60. if (loading) {
  61. loading.remove();
  62. loading = undefined;
  63. }
  64. }
  65.  
  66. const nextPageA = document.querySelector('.setnmh-next.mhicon.icon-jiantou-right');
  67. if (window != window.top) {
  68. const interval = setInterval(() => {
  69. const img = document.querySelector('.setnmh-seebox img');
  70. if (!img) return;
  71.  
  72. clearInterval(interval);
  73. window.top.postMessage({ nextPagePath: nextPageA?.href, image: img.src }, location.origin);
  74. }, 100);
  75. return;
  76. }
  77.  
  78. window.addEventListener('message', e => {
  79. if (e.data.image) {
  80. processImage(event.data.image);
  81. }
  82. if (e.data.nextPagePath) {
  83. processPage(e.data.nextPagePath);
  84. } else {
  85. hideLoading();
  86. }
  87. });
  88.  
  89. if (nextPageA) processPage(nextPageA.href);
  90. })();

QingJ © 2025

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