ZhihuZhuangbilityExterminator

turn every fuckin' Zhihu-style right quote into normal quote 让逼乎直角引号见乔布斯去吧!只要看见狗日的直角引号,点点按钮它们就能全部消失不见

当前为 2017-08-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ZhihuZhuangbilityExterminator
  3. // @namespace nein
  4. // @author ddOs
  5. // @description turn every fuckin' Zhihu-style right quote into normal quote 让逼乎直角引号见乔布斯去吧!只要看见狗日的直角引号,点点按钮它们就能全部消失不见
  6. // @include http://*.zhihu.com/*
  7. // @include https://*.zhihu.com/*
  8. // @version 1
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. // references:
  13. // https://greasyfork.org/en/scripts/25776-coincidence-detector for replacing method
  14. // https://stackoverflow.com/questions/6480082/add-a-javascript-button-using-greasemonkey-or-tampermonkey for button
  15.  
  16. var zNode = document.createElement('div');
  17. zNode.innerHTML = '<button id="myButton" type="button">'+ 'Fuck 果乎/逼乎/绿乎/whatever乎<br /> right in the pussy! </button>';
  18. zNode.setAttribute('id', 'myContainer');
  19. document.body.appendChild(zNode);
  20. //position = document.getElementByClass('CornerButtons')
  21. //position.appendChild(zNode);
  22. //--- Activate the newly added button.
  23. document.getElementById('myButton').addEventListener('click', ButtonClickAction, false
  24. );
  25. function ButtonClickAction(zEvent) {
  26. (function () {
  27. function walk(node) {
  28. // I stole this function from here:
  29. // http://is.gd/mwZp7E
  30. var child,
  31. next;
  32. switch (node.nodeType)
  33. {
  34. case 1:
  35. case 9:
  36. case 11:
  37. child = node.firstChild;
  38. while (child)
  39. {
  40. next = child.nextSibling;
  41. walk(child);
  42. child = next;
  43. }
  44. break;
  45. case 3:
  46. handleText(node);
  47. break;
  48. }
  49. }
  50. function handleText(textNode) {
  51. textNode.nodeValue = textNode.nodeValue.replace('「', '“');
  52. textNode.nodeValue = textNode.nodeValue.replace('」', '”');
  53. textNode.nodeValue = textNode.nodeValue.replace('『', '‘');
  54. textNode.nodeValue = textNode.nodeValue.replace('』', '’');
  55. }
  56. walk(document.body);
  57. }) ();
  58. }//--- Style our newly added elements using CSS.
  59.  
  60. GM_addStyle(multilineStr(function () { /*!
  61. #myContainer {
  62. position: fixed;
  63. top: 0;
  64. left: 0;
  65. font-size: 20px;
  66. background: orange;
  67. border: 3px outset black;
  68. margin: 5px;
  69. opacity: 0.9;
  70. z-index: 1100;
  71. padding: 5px 20px;
  72. }
  73. #myButton {
  74. cursor: pointer;
  75. }
  76. #myContainer p {
  77. color: red;
  78. background: white;
  79. }
  80. */
  81. }));
  82. function multilineStr(dummyFunc) {
  83. var str = dummyFunc.toString();
  84. str = str.replace(/^[^\/]+\/\*!?/, '') // Strip function () { /*!
  85. .replace(/\s*\*\/\s*\}\s*$/, '') // Strip */ }
  86. .replace(/\/\/.+$/gm, '') // Double-slash comments wreck CSS. Strip them.
  87. ;
  88. return str;
  89. }