您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Catch unsaved comments/posts
// ==UserScript== // @name [PTP] Catch unsaved comments/posts // @namespace kannibalox // @match https://passthepopcorn.me/* // @grant none // @version 1.0 // @author kannibalox // @license GNU GPLv3 // @description Catch unsaved comments/posts // ==/UserScript== "use strict"; const beforeUnloadListener = (e) => { e.preventDefault(); return e.returnValue = ''; }; function main() { var textInput = document.querySelector("#quickpost"); var submitInput = document.querySelector("#quickpostform"); if (textInput !== null && submitInput !== null) { textInput.addEventListener("input", (event) => { if (event.target.value !== "") { addEventListener("beforeunload", beforeUnloadListener, {capture: true}); } else { removeEventListener("beforeunload", beforeUnloadListener, {capture: true}); } }); submitInput.addEventListener("submit", (event) => { removeEventListener("beforeunload", beforeUnloadListener, {capture: true}); }); } } window.addEventListener('load', main(), false);