NotSoSharp

尝试还原萌娘百科部分一方通行所屏蔽的内容

当前为 2023-05-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NotSoSharp
  3. // @namespace https://github.com/gui-ying233/NotSoSharp
  4. // @version 1.1.0
  5. // @description 尝试还原萌娘百科部分一方通行所屏蔽的内容
  6. // @author 鬼影233
  7. // @license MIT
  8. // @match *.moegirl.org.cn/*
  9. // @icon https://img.moegirl.org.cn/common/b/b7/%E5%A4%A7%E8%90%8C%E5%AD%97.svg
  10. // @supportURL https://github.com/gui-ying233/NotSoSharp/issues
  11. // ==/UserScript==
  12.  
  13. (async function () {
  14. "use strict";
  15. if (
  16. document.documentElement.textContent.includes("\u266F") &&
  17. document.documentElement.innerText.includes("\u266F")
  18. ) {
  19. let pageName = "";
  20. await new Promise((resolve) => {
  21. setInterval(() => {
  22. window.onload = (() => {
  23. if (
  24. typeof mw !== "undefined" &&
  25. typeof wgULS !== "undefined"
  26. ) {
  27. resolve();
  28. }
  29. })();
  30. }, 50);
  31. });
  32. switch (mw.config.get("wgNamespaceNumber")) {
  33. case 2:
  34. case 3:
  35. pageName = wgULS("用户", "用戶");
  36. break;
  37. case 10:
  38. case 11:
  39. pageName = "模板";
  40. break;
  41. case 14:
  42. case 15:
  43. pageName = wgULS("分类", "分類");
  44. break;
  45. default:
  46. break;
  47. }
  48. switch (mw.config.get("wgNamespaceNumber")) {
  49. case 1:
  50. case 3:
  51. case 5:
  52. case 9:
  53. case 11:
  54. case 13:
  55. case 15:
  56. pageName += wgULS("讨论", "討論");
  57. break;
  58. default:
  59. break;
  60. }
  61. pageName += `${pageName ? ":" : ""}${mw.config.get("wgTitle")}`;
  62. function r(a, b, c = pageName) {
  63. if (a[b].includes("\u266F")) {
  64. a[b] = c;
  65. }
  66. }
  67. r(document.getElementById("firstHeading"), "innerText");
  68. r(document, "title", `${pageName} - 萌娘百科_万物皆可萌的百科全书`);
  69. switch (mw.config.get("skin")) {
  70. case "vector":
  71. document.body.querySelectorAll(".toctext").forEach((e) => {
  72. r(e, "innerText", decodeURI(e.parentElement.hash.slice(1)));
  73. });
  74. break;
  75. case "moeskin":
  76. default:
  77. document.body
  78. .querySelectorAll(".moe-toc-tree.root a.anchor-link")
  79. .forEach((e) => {
  80. r(e, "title", decodeURI(e.hash.replaceAll(".", "%")));
  81. });
  82. document.body
  83. .querySelectorAll(
  84. ".moe-toc-tree.root a.anchor-link > .text"
  85. )
  86. .forEach((e) => {
  87. r(
  88. e,
  89. "innerText",
  90. decodeURI(
  91. e.parentElement.hash.replaceAll(".", "%")
  92. ).slice(1)
  93. );
  94. });
  95. break;
  96. }
  97. document.body.querySelectorAll(".mw-headline").forEach((e) => {
  98. r(e, "innerText", decodeURI(e.id));
  99. });
  100. document.body.querySelectorAll("a:not(#catlinks a)").forEach((e) => {
  101. if (e.innerText.includes("\u266F")) {
  102. if (
  103. new Set(e.innerHTML).size === 1 ||
  104. e.classList.contains("mw-changeslist-title") ||
  105. e.classList.contains("mw-userlink")
  106. ) {
  107. e.innerText =
  108. new URL(e).searchParams.get("title") ||
  109. e.getAttribute("data-username") ||
  110. decodeURI(e.pathname).slice(1);
  111. }
  112. }
  113. });
  114. document.body.querySelectorAll("#catlinks a").forEach((e) => {
  115. if (
  116. e.innerText.includes("\u266F") &&
  117. new Set(e.innerHTML).size === 1
  118. ) {
  119. e.innerText = decodeURI(e.pathname).slice(10);
  120. }
  121. });
  122. }
  123. })();