Masiro Block User

31/03/2023, 5:40:10 am

  1. // ==UserScript==
  2. // @name Masiro Block User
  3. // @namespace Violentmonkey Scripts
  4. // @license GPL
  5. // @match *://masiro.me/*
  6. // @require https://openuserjs.org/src/libs/sizzle/GM_config.js
  7. // @grant GM_getValue
  8. // @grant GM_setValue
  9. // @grant GM.getValue
  10. // @grant GM.setValue
  11. // @version 1.0
  12. // @author Hou Rui
  13. // @description 31/03/2023, 5:40:10 am
  14. // ==/UserScript==
  15.  
  16. let config = new GM_config({
  17. 'id': 'MisiroBlockUserConfig',
  18. 'title': 'Masiro Block User',
  19. 'fields': {
  20. 'blockedUsers': {
  21. 'label': '每行输入一个用户名',
  22. 'section': ['屏蔽用户列表'],
  23. 'type': 'textarea',
  24. }
  25. },
  26. 'events': {
  27. 'init': loadConfig,
  28. 'save': loadConfig,
  29. },
  30. 'css': '#MisiroBlockUserConfig textarea { width: 100%; height: 70%; }'
  31. })
  32.  
  33. function loadConfig() {
  34. let blockNames = config.get('blockedUsers').split('\n').map(line => line.trim())
  35. console.log(`Blocked users: ${blockNames}`)
  36.  
  37. let contentBlocks = document.querySelectorAll('span.reply_content, div.comment-content')
  38. for (let block of contentBlocks) {
  39. let attrs = block.attributes['data-name']
  40. if (attrs === undefined) {
  41. return;
  42. }
  43. let userName = attrs.value
  44. if (blockNames.includes(userName)) {
  45. block.innerHTML = '[已屏蔽]'
  46. let sibling = block.parentElement.nextElementSibling
  47. if (sibling === null) {
  48. return;
  49. }
  50. if (sibling.className === 'reply_list') {
  51. sibling.innerHTML = ''
  52. }
  53. }
  54. }
  55. }
  56.  
  57. let commentButton = document.getElementById('comment-btn')
  58. let configButton = document.createElement('button')
  59.  
  60. configButton.classList.add('btn', 'btn-primary')
  61. configButton.textContent = '屏蔽设置'
  62. configButton.style.float = 'right'
  63. configButton.style.padding = commentButton.style.padding;
  64. configButton.style.marginRight = commentButton.style.marginRight;
  65. configButton.style.fontSize = commentButton.style.fontSize;
  66. configButton.onclick = () => config.open()
  67.  
  68. commentButton.parentNode.appendChild(configButton)

QingJ © 2025

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