S1 User Blocker

Block certain user's content

目前為 2021-01-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name S1 User Blocker
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Block certain user's content
  6. // @author 冰箱研会长
  7. // @match https://bbs.saraba1st.com/2b/*
  8. // ==/UserScript==
  9.  
  10. var User_Blocked = new Array(`要屏蔽的用户1`,`这里用的是键盘左上角的backtick符号`,`逗号分隔主体`);
  11. var Correspond_Section = new Array(`和用户1对应的板块名称`,`PC数码`,`动漫论坛PC数码`);
  12.  
  13. function getElementByXpath(path) {
  14. return document.evaluate(path, document, null,
  15. XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  16. }
  17.  
  18.  
  19. function S1_Reply_Blocker(){
  20. var PostLists = getElementByXpath(`/html/body/div[8]/div[4]/div[2]`);
  21. if(PostLists){
  22. //check if exist
  23. if(PostLists.id == `mdly`){
  24. //if this is your thread, the xpath of threadlist will be 8 4 3
  25. //8 4 2 will have id "mdly"
  26. PostLists = getElementByXpath(`/html/body/div[8]/div[4]/div[3]`);
  27. if(PostLists){
  28. //check if new postlists exist, if so, append normal procedure but for 842
  29. var PostCounter = 1;
  30. while(getElementByXpath(`/html/body/div[8]/div[4]/div[3]/div[${PostCounter}]`)){
  31. var PostAuthor = getElementByXpath(`/html/body/div[8]/div[4]/div[3]/div[${PostCounter}]/table/tbody/tr[1]/td[1]/div/div[1]/div/a`);
  32. if(PostAuthor){
  33. if( User_Blocked.includes(PostAuthor.innerText) ){
  34. var PostSection = getElementByXpath(`/html/body/div[8]/div[3]/div/a[4]`).innerText;
  35. if(Correspond_Section[User_Blocked.indexOf(PostAuthor.innerText)] == ""){
  36. getElementByXpath(`/html/body/div[8]/div[4]/div[3]/div[${PostCounter}]`).style.display = `none`;
  37. }else if(Correspond_Section[User_Blocked.indexOf(PostAuthor.innerText)].includes(PostSection)){
  38. getElementByXpath(`/html/body/div[8]/div[4]/div[3]/div[${PostCounter}]`).style.display = `none`;
  39. }
  40. }
  41. }
  42. PostCounter = PostCounter + 1;
  43. }
  44. }
  45. }else{
  46. //this is not your thread, so normal 842 will be active
  47. var PostCounter = 1;
  48. while(getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]`)){
  49. var PostAuthor = getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]/table/tbody/tr[1]/td[1]/div/div[1]/div/a`);
  50. if(PostAuthor){
  51. if( User_Blocked.includes(PostAuthor.innerText) ){
  52. var PostSection = getElementByXpath(`/html/body/div[8]/div[2]/div/a[4]`).innerText;
  53. if(Correspond_Section[User_Blocked.indexOf(PostAuthor.innerText)] == ""){
  54. getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]`).style.display = `none`;
  55. }else if(Correspond_Section[User_Blocked.indexOf(PostAuthor.innerText)].includes(PostSection)){
  56. getElementByXpath(`/html/body/div[8]/div[4]/div[2]/div[${PostCounter}]`).style.display = `none`;
  57. }
  58. }
  59. }
  60. PostCounter = PostCounter + 1;
  61. }
  62. }
  63. }
  64.  
  65. }
  66.  
  67. function S1_Sure_Blocker(){
  68. var SureList = getElementByXpath('/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table');
  69. if(SureList){
  70. var SureCounter = 1;
  71. while(getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]`)){
  72. var SureAuthor = getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]/tr/td[2]/cite/a`);
  73. if(SureAuthor){
  74. if(User_Blocked.includes(SureAuthor.innerText)){
  75. var SureSection = getElementByXpath(`/html/body/div[8]/div[2]/div/a[4]`).innerText;
  76. if(Correspond_Section[User_Blocked.indexOf(SureAuthor.innerText)] == ""){
  77. getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]`).style.display = `none`;
  78. }else if(Correspond_Section[User_Blocked.indexOf(SureAuthor.innerText)].includes(SureSection)){
  79. getElementByXpath(`/html/body/div[8]/div[4]/div/div/div[5]/div[2]/form/table/tbody[${SureCounter}]`).style.display = `none`;
  80. }
  81. }
  82. }
  83. SureCounter = SureCounter + 1;
  84. }
  85. }
  86. }
  87.  
  88. S1_Reply_Blocker();
  89. S1_Sure_Blocker();

QingJ © 2025

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