Geekhub ban user

A extension for ban user on https://geekhub.com

  1. // ==UserScript==
  2. // @name Geekhub ban user
  3. // @namespace http://ora.moe/
  4. // @version 0.2
  5. // @description A extension for ban user on https://geekhub.com
  6. // @author You
  7. // @match https://geekhub.com/*
  8. // @grant none
  9. // ==/UserScript==
  10. var thisw=window
  11. JSON.tryparse=function(...e){
  12. try{
  13. return JSON.parse.apply(this,e)
  14. }catch(e){
  15. return {}
  16. }
  17. }
  18. if(JSON.tryparse(localStorage["blackObj"]).blacklist===undefined){
  19. localStorage["blackObj"]=JSON.stringify({blacklist:[]})
  20. }
  21. thisw.blacklist=JSON.tryparse(localStorage["blackObj"]).blacklist
  22. thisw.BanUser=function(username){
  23. var select=confirm("你确定将"+username+"加入黑名单?")
  24. if(select){
  25. blacklist[blacklist.length]=username
  26. var BlackObj={blacklist}
  27. localStorage["blackObj"]=JSON.stringify(BlackObj)
  28. location.reload()
  29. return false
  30. }
  31. }
  32. document.querySelectorAll(".flex.items-center.px-2.py-3.border-t.border-color").forEach(e=>{
  33. if(blacklist.includes(e.children[1].children[1].children[2].children[0].innerHTML)){
  34. e.style.display="none"
  35. }
  36. })
  37. document.body.outerHTML+="<hr><h2>Ban User for Geekhub</h2><h2>当前屏蔽用户:"+blacklist.join(",")+`</h2><hr><a href='javascript:delete localStorage["blackObj"];location.reload()'>一键清除</a><br><input type="text" onchange="javascript:BanUser(this.value)" placeholder="待封禁用户名..."></input>`