NotSoSharp

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

当前为 2023-06-01 提交的版本,查看 最新版本

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