AA for S1

Modify Stage1 text property for AA

  1. // ==UserScript==
  2. // @name AA for S1
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description Modify Stage1 text property for AA
  6. // @author 冰箱研会长
  7. // @match https://bbs.saraba1st.com/2b/*
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @require http://code.jquery.com/jquery-3.5.1.min.js
  11. // @require https://greasyfork.org/scripts/420061-super-gm-setvalue-and-gm-getvalue-greasyfork-mirror-js/code/Super_GM_setValue_and_GM_getValue_greasyfork_mirrorjs.js?version=890160
  12. // ==/UserScript==
  13.  
  14.  
  15. var AA_author_array = GM_SuperValue.get(`AA Author`, new Array());
  16.  
  17.  
  18. function getElementByXpath(path) {
  19. return document.evaluate(path, document, null,
  20. XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  21. }
  22.  
  23. function Reset_BlockCode(NodeRoot) {
  24. var CodeBlocks = NodeRoot.getElementsByClassName("blockcode");
  25. if (CodeBlocks) {
  26. for (var i = 0; i < CodeBlocks.length; i++) {
  27. var CodeBlock = CodeBlocks[i];
  28. CodeBlock.style.fontSize = "12px";
  29. CodeBlock.style.lineHeight = "22px";
  30. CodeBlock.style.fontFamily = "Monaco, Consolas, Lucida Console, Courier New, serif";
  31. CodeBlock.style.whiteSpace = "normal";
  32. }
  33. }
  34.  
  35. }
  36.  
  37. function Reset_BlockQuote(NodeRoot) {
  38. var QuoteBlocks = NodeRoot.getElementsByClassName("blockquote");
  39. if (QuoteBlocks) {
  40. for (var i = 0; i < QuoteBlocks.length; i++) {
  41. var QuoteBlock = QuoteBlocks[i];
  42. QuoteBlock.style.fontSize = "12px";
  43. QuoteBlock.style.lineHeight = "22px";
  44. QuoteBlock.style.fontFamily = "Monaco, Consolas, Lucida Console, Courier New, serif";
  45. QuoteBlock.style.whiteSpace = "pre-wrap";
  46. }
  47. }
  48.  
  49. }
  50.  
  51. function Blockbutton_Appender(HtmlDiv, Post_Author, Counter) {
  52. HtmlDiv.innerHTML = HtmlDiv.innerHTML.concat(`
  53. <div><button type="button" id="enable-${Counter}">标记为AA发布者</button></div>
  54. <div><button type="button" id="disable-${Counter}">取消标记</button></div>
  55. `);
  56.  
  57. $(`#enable-${Counter}`).click({ pa: Post_Author }, function (event) {
  58.  
  59. if (AA_author_array.includes(event.data.pa)) {
  60. console.log(`AA:${event.data.pa}已经被标记了!`);
  61. } else {
  62. AA_author_array.push(event.data.pa);
  63. console.log(`AA:${event.data.pa}标记完成!`);
  64. }
  65. GM_SuperValue.set(`AA Author`, AA_author_array);
  66. });
  67.  
  68. $(`#disable-${Counter}`).click({ pa: Post_Author }, function (event) {
  69. if (AA_author_array.includes(event.data.pa)) {
  70. AA_author_array[AA_author_array.indexOf(event.data.pa)] = ``;
  71. console.log(`AA:${event.data.pa}标记已取消!`);
  72. } else {
  73. console.log(`AA:${event.data.pa}未被标记!`);
  74. }
  75. GM_SuperValue.set(`AA Author`, AA_author_array);
  76. });
  77.  
  78.  
  79. }
  80.  
  81.  
  82. function AAPosts_Modifier() {
  83. var PostLists = getElementByXpath(`//div[@id='postlist']`);
  84. if (PostLists) {
  85. var PostCounter = 1;
  86. while (getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]`)) {
  87. var PostAuthor = getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]/table/tbody/tr[1]/td[1]/div/div[1]/div/a`);
  88. var PostAruthorColumn = getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]/table[1]/tbody[1]/tr[1]/td[1]/div[1]`);
  89. if (PostAruthorColumn) {
  90. Blockbutton_Appender(PostAruthorColumn, PostAuthor.innerText,PostCounter);
  91. }
  92. if (PostAuthor) {
  93. if (AA_author_array.includes(PostAuthor.innerText)) {
  94. var ReplyBox = getElementByXpath(`//div[@id='postlist']/div[${PostCounter}]/table/tbody/tr[1]/td[2]/div[2]/div/div[1]/table/tbody/tr/td`);
  95. ReplyBox.style.fontSize = "16px";
  96. ReplyBox.style.lineHeight = "18px";
  97. ReplyBox.style.fontFamily = "MS PGothic";
  98. ReplyBox.style.whiteSpace = "normal";
  99. Reset_BlockCode(ReplyBox);
  100. Reset_BlockQuote(ReplyBox);
  101. }
  102. }
  103. PostCounter = PostCounter + 1;
  104. }
  105. }
  106. }
  107.  
  108.  
  109. AAPosts_Modifier();