Clarify Cognition over Ontology

所有的 /(.过)/ 改成 "自认为$1"

  1. // ==UserScript==
  2. // @name Clarify Cognition over Ontology
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.1
  5. // @description 所有的 /(.过)/ 改成 "自认为$1"
  6. // @author InQβ(no1xsyzy)
  7. // @match https://bgm.tv/*
  8. // @match https://bangumi.tv/*
  9. // @match https://chii.in/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. const debug = false;
  16. const $ = selector => document.querySelector(selector)
  17. const $$ = selector => Array.from(document.querySelectorAll(selector))
  18. const prepends = debug ? text => {
  19. console.log(text);
  20. const new_text = text.replace(/(.过)/, "自认为$1")
  21. console.log(new_text)
  22. return new_text
  23. } : text => text.replace(/(.过)/, "自认为$1")
  24. const do_prepend_textContent = debug? el => {
  25. console.log(el)
  26. el.textContent = prepends(el.textContent)
  27. console.log(el)
  28. } : el => {el.innerText = prepends(el.textContent)}
  29.  
  30. const launchObserver = ({
  31. parentNode,
  32. selector,
  33. failCallback = null,
  34. successCallback = null,
  35. stopWhenSuccess = true,
  36. config = {
  37. childList: true,
  38. subtree: true
  39. }
  40. }) => {
  41. // if parent node does not exist, return
  42. if (!parentNode) { return }
  43. const observeFunc = mutationList => {
  44. if (!document.querySelector(selector)) {
  45. if (failCallback) { failCallback() }
  46. return
  47. }
  48. if (stopWhenSuccess) { observer.disconnect() }
  49. if (successCallback) { successCallback() }
  50. }
  51. const observer = new MutationObserver(observeFunc)
  52. observer.observe(parentNode, config)
  53. }
  54. if (debug){
  55. window.prepends = prepends
  56. window.do_prepend_textContent = do_prepend_textContent
  57. window.launchObserver = launchObserver
  58. }
  59.  
  60. $$(`a[href$="collect"]`).forEach(do_prepend_textContent)
  61. $$(`ul.collect_dropmenu>li>a`).forEach(do_prepend_textContent)
  62. $$(`#subjectPanelCollect>ul div.innerWithAvatar>small`).forEach(do_prepend_textContent)
  63. $$(`#subjectPanelCollect>.tip_i a[href$="collections"]`).forEach(do_prepend_textContent)
  64. $$(`title`).forEach(do_prepend_textContent)
  65. $$(`.interest_now`).forEach(do_prepend_textContent)
  66. $$(`#SecTab span`).forEach(do_prepend_textContent)
  67. // launchObserver({
  68. // parentNode: $(`#TB_window`),
  69. // selector: `.collectType.cell label`,
  70. // successCallback: () => $$(`.collectType.cell label`).map(label => label.childNodes[1]).forEach(do_prepend_textContent)
  71. // })
  72. $$(`.collectType.cell label`).map(label => label.childNodes[1]).forEach(do_prepend_textContent)
  73. })();

QingJ © 2025

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