Show not checked content

Shows content hidden by Valve's automated content check system

当前为 2020-08-27 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Show not checked content
  3. // @namespace https://greasyfork.org/users/2205
  4. // @version 0.3
  5. // @description Shows content hidden by Valve's automated content check system
  6. // @author Ryzhehvost
  7. // @license Apache-2.0
  8. // @match https://steamcommunity.com/groups/*/discussions/*
  9. // @match https://steamcommunity.com/discussions/forum/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. /* global g_rgForumTopicCommentThreads */
  16. /* global g_rgForumTopics*/
  17. function GetText( gidTopic, gidComment )
  18. {
  19. var CommentThread = g_rgForumTopicCommentThreads[gidTopic];
  20. var rgRawComment;
  21. if ( gidComment && gidComment != -1 )
  22. {
  23. rgRawComment = CommentThread.GetRawComment( gidComment );
  24. }
  25. else
  26. {
  27. // topic quoting
  28. rgRawComment = g_rgForumTopics[gidTopic].m_rgRawData;
  29. }
  30. return rgRawComment.text;
  31. }
  32.  
  33. function FormatBBCode(text){
  34. let re = /[noparse](.*)[/noparse]/gs;
  35. let noparse = text.match(re);
  36. re = /\[h1\](.*?)\[\/h1\]/gs;
  37. text = text.replace(re, '<div class="bb_h1">$1</div>');
  38. re = /\[b\](.*?)\[\/b\]/gs;
  39. text = text.replace(re, '<b>$1</b>');
  40. re = /\[u\](.*?)\[\/u\]/gs;
  41. text = text.replace(re, '<u>$1</u>');
  42. re = /\[i\](.*?)\[\/i\]/gs;
  43. text = text.replace(re, '<i>$1</i>');
  44. re = /\[strike\](.*?)\[\/strike\]/gs;
  45. text = text.replace(re, '<span class="bb_strike">$1</span>');
  46. re = /\[spoiler\](.*)\[\/spoiler\]/gs;
  47. text = text.replace(re, '<span class="bb_spoiler"><span>$1</span></span>');
  48. re = /\[url=(.*?)\](.*?)\[\/url\]/gs;
  49. text = text.replace(re, '<a class="bb_link" href="$1" target="_blank" rel="noreferrer">$2</a>');
  50. re = /([^>"]|^)https?:\/\/store.steampowered.com\/app\/(\d*)[^\s]*/g;
  51. text = text.replace(re, '$1<br/><iframe src="https://store.steampowered.com/widget/$2/?dynamiclink=1" width="100%" height="190" frameborder="0"></iframe>');
  52. re = /([^>"]|^)(http|https|ftp)(:\/\/[^\s]*)/gs;
  53. text = text.replace(re, '$1<a class="bb_link" href="$1" target="_blank" rel="noreferrer">$2$3</a>');
  54. re = /\[quote=([^;]*?)\](.*?)\[\/quote\]/gs;
  55. text = text.replace(re, '<blockquote class="bb_blockquote with_author"><div class="bb_quoteauthor">Originally posted by <b>$1</b>:</div>$2</blockquote>');
  56. re = /\[quote=([^;]*?);(\d*)\](.*?)\[\/quote\]/gs;
  57. text = text.replace(re, '<blockquote class="bb_blockquote with_author"><div class="bb_quoteauthor">Originally posted by <b><a href="#c$2">$1</a></b>:</div>$3</blockquote>');
  58. re = /\[quote\](.*?)\[\/quote\]/gs;
  59. text = text.replace(re, '<blockquote class="bb_blockquote">$1</blockquote>');
  60. re = /\[code\](.*?)\[\/code\]/gs;
  61. text = text.replace(re, '<div class="bb_code">$1</div>');
  62. re = /\[list\](.*?)\[\/list\]/gms;
  63. text = text.replace(re, '<ul class="bb_ul">$1</ul>');
  64. re = /\[olist\](.*?)\[\/olist\]/gms;
  65. text = text.replace(re, '<ol>$1</ol>');
  66. re = /\[\*\](.*?)$/gms;
  67. text = text.replace(re, '<li>$1</li>');
  68. let index = 0;
  69. re = /\[noparse\](.*?)\[\/noparse\]/g;
  70. text = text.replace(re,() => noparse[index++]);
  71. return text;
  72. }
  73.  
  74. function FixComments (comments){
  75. for (let i=comments.length-1; i>=0; i--) {
  76. let parent = comments[i].parentNode;
  77. let gidComment = parent.id.split('_')[2];
  78. parent.innerHTML = FormatBBCode(GetText( gidTopic, gidComment));
  79. //add a notice
  80. let noticeDiv = document.createElement("span");
  81. noticeDiv.className = "forum_comment_author_banned";
  82. noticeDiv.appendChild(document.createTextNode("(post awaiting analysis)"));
  83. parent.parentElement.querySelector("div.forum_author_menu").after(noticeDiv);
  84. }
  85. }
  86.  
  87. let re = /.*discussions\/\d+\/(\d+)/g;
  88. let res = re.exec(document.URL);
  89. if (res===null){
  90. re = /.*forum\/\d+\/(\d+)/g;
  91. res = re.exec(document.URL);
  92. }
  93. let gidTopic = res[1];
  94. let comments = document.getElementsByClassName('needs_content_check');
  95. FixComments(comments);
  96.  
  97. let mutationObserver = new MutationObserver(function(mutations) {
  98. mutations.forEach(function(mutation) {
  99. mutation.addedNodes.forEach( function(currentValue, currentIndex, listObj) {
  100. if (currentValue.nodeType == Node.ELEMENT_NODE) {
  101. let comments = currentValue.querySelectorAll("div[class^='needs_content_check']");
  102. FixComments(comments);
  103. }
  104. });
  105. });
  106. });
  107. mutationObserver.observe(document.documentElement, {
  108. childList: true,
  109. subtree: true
  110. });
  111.  
  112. })();