Twitch Confirm Message Send

Confirms Twitch Chat Messages

当前为 2019-02-13 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          Twitch Confirm Message Send
// @namespace     http://userstyles.org
// @description   Confirms Twitch Chat Messages
// @author        636597
// @include       *://*.twitch.tv/*
// @run-at        document-start
// @version       0.2
// ==/UserScript==

// Broken For Now Because:
// A window.confirm() dialog generated by this page was suppressed because this page is not the active tab of the front window. Please make sure your dialogs are triggered by user interactions to avoid this situation.

// Need some non blocking confirm modal
// https://stackoverflow.com/questions/878710/is-a-modal-confirm-box-using-jquery-possible


/*
var chat_box_send_button_query_selector = '[data-a-target="chat-send-button"]';
var chat_box_send_button_element = null;
var chat_box_element_query_selector = '[data-a-target="chat-input"]';
var chat_box_element = null;
var chat_box_observer = null;
var observerConfig = {
	attributes: true,
	childList: true,
	characterData: true
};

function loadObserver() {

	// chat_box_observer = new MutationObserver( function( mutations ) {
	// 	mutations.forEach(function( mutation , index ) {
	// 		if ( mutation.type === "childList" ) {
	// 			var addedNode = mutation.addedNodes[ 0 ];
	// 			if( addedNode ) {
	// 				console.log( addedNode );
	// 			}
	// 		}
	// 	});
	// });
	// chat_box_observer.observe( chat_box_element , observerConfig );

	chat_box_element.addEventListener( "keydown" , function( event ) {
		if ( event.key === "Enter" ) {
			if ( confirm( "Do you want to post message?" ) === true ) {
				console.log( "passing" );
			} else {
				event.stopImmediatePropagation();
				event.stopPropagation();
				event.preventDefault();
				return false;
			}
		}
	});
	chat_box_send_button_element.addEventListener( "click" , function( event ) {
		if ( confirm( "Do you want to post message?" ) === true ) {
			console.log( "passing" );
		} else {
			event.stopImmediatePropagation();
			event.stopPropagation();
			event.preventDefault();
			return false;
		}
	});
	console.log( "Twitch Message Confirm Loaded" );
}


(function() {
	var ready = setInterval(function(){
		var x1 = document.querySelectorAll( chat_box_element_query_selector );
		if ( x1 ) { if ( x1[ 0 ] ) {
			chat_box_element = x1[0];
			var x2 = document.querySelectorAll( chat_box_send_button_query_selector );
			if ( x2 ) { if ( x2[ 0 ] ) {
				chat_box_send_button_element = x2[ 0 ];
				clearInterval( ready );
				loadObserver();
			}}
		}}
	} , 2 );
	setTimeout( function() { clearInterval( ready ); } , 20000 );
})();
*/