🏠 返回首頁 

Greasy Fork is available in English.

Keylol_Mobile_Tweaker

移除一些元素

  1. // ==UserScript==
  2. // @name:zh-CN Keylol_手机版优化
  3. // @name Keylol_Mobile_Tweaker
  4. // @namespace https://blog.chrxw.com
  5. // @supportURL https://blog.chrxw.com/scripts.html
  6. // @contributionURL https://afdian.com/@chr233
  7. // @version 1.0
  8. // @description 移除一些元素
  9. // @description:zh-CN 移除一些元素
  10. // @author Chr_
  11. // @match https://keylol.com/*
  12. // @license AGPL-3.0
  13. // @icon https://blog.chrxw.com/favicon.ico
  14. // ==/UserScript==
  15. (() => {
  16. "use strict";
  17. const isPc = !!document.querySelector('a[href="forum.php?mobile=yes"]')
  18. if (!isPc) {
  19. const replay = document.getElementById('fastpostform');
  20. if (replay) {
  21. replay.style.display = "none";
  22. }
  23. }
  24. tweakerBtns();
  25. const observer = new MutationObserver((mutations) => {
  26. mutations.forEach((mutation) => {
  27. if (mutation.addedNodes.length > 0) {
  28. tweakerBtns();
  29. }
  30. });
  31. });
  32. observer.observe(document.body, { childList: true, subtree: true });
  33. function tweakerBtns() {
  34. const rateBtns = document.querySelectorAll('div[id^="dppf"]>a');
  35. if (rateBtns.length > 0) {
  36. for (let btn of rateBtns) {
  37. const span = document.createElement('span');
  38. span.innerHTML = btn.innerHTML;
  39. span.style.margin = "0 3px";
  40. btn.parentNode.replaceChild(span, btn);
  41. }
  42. }
  43. const ratePcBtns = document.querySelectorAll('div.pob.cl>em>a');
  44. if (ratePcBtns.length > 0) {
  45. for (let btn of ratePcBtns) {
  46. const span = document.createElement('span');
  47. span.innerHTML = btn.innerHTML;
  48. span.className = btn.className;
  49. span.style.padding = "5px 10px 5px 25px";
  50. btn.parentNode.replaceChild(span, btn);
  51. }
  52. }
  53. }
  54. })();