mastodon-confirm-no-replying

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name     mastodon-confirm-no-replying
// @namespace http://gholk.github.io
// @version  1
// @grant    none
// @license GPLv3
// @description prevent user post a replying toot without click *reply* button of the origin toot.
// @include https://g0v.social/*
// @exclude https://g0v.social/settings/*
// ==/UserScript==


window.addEventListener('keydown', e=>{
  const t = e.target;
  if (!(e.key == 'Enter' && e.ctrlKey)) return true
  if (t.nodeName == 'TEXTAREA' && t.matches('.autosuggest-textarea__textarea')) {
    const f = t.form;
    confirmNotReply(f, e)
  }
}, {
  capture: true,
  passive: false
})
window.addEventListener('click', e=>{
  const b = e.target;
  if (b.matches('.compose-form__publish-button-wrapper *')) {
    const f = b.closest('form');
    confirmNotReply(f, e)
  }
}, {
  capture: true,
  passive: false
})
function confirmNotReply(form, event) {
    const f = form
    const e = event
    if (f.querySelector('.reply-indicator')) return;
    if (confirm('not replying, toot this?')) return;
    e.preventDefault();
    e.stopImmediatePropagation()
}