mastodon-confirm-no-replying

prevent user post a replying toot without click *reply* button of the origin toot.

  1. // ==UserScript==
  2. // @name mastodon-confirm-no-replying
  3. // @namespace http://gholk.github.io
  4. // @version 1
  5. // @grant none
  6. // @license GPLv3
  7. // @description prevent user post a replying toot without click *reply* button of the origin toot.
  8. // @include https://g0v.social/*
  9. // @exclude https://g0v.social/settings/*
  10. // ==/UserScript==
  11.  
  12.  
  13. window.addEventListener('keydown', e=>{
  14. const t = e.target;
  15. if (!(e.key == 'Enter' && e.ctrlKey)) return true
  16. if (t.nodeName == 'TEXTAREA' && t.matches('.autosuggest-textarea__textarea')) {
  17. const f = t.form;
  18. confirmNotReply(f, e)
  19. }
  20. }, {
  21. capture: true,
  22. passive: false
  23. })
  24. window.addEventListener('click', e=>{
  25. const b = e.target;
  26. if (b.matches('.compose-form__publish-button-wrapper *')) {
  27. const f = b.closest('form');
  28. confirmNotReply(f, e)
  29. }
  30. }, {
  31. capture: true,
  32. passive: false
  33. })
  34. function confirmNotReply(form, event) {
  35. const f = form
  36. const e = event
  37. if (f.querySelector('.reply-indicator')) return;
  38. if (confirm('not replying, toot this?')) return;
  39. e.preventDefault();
  40. e.stopImmediatePropagation()
  41. }

QingJ © 2025

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