AFK-command (for Chrome 1.x)

Adds /afk to chat as well as an afk message

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           AFK-command (for Chrome 1.x)
// @namespace      ventero.de
// @description    Adds /afk to chat as well as an afk message
// @include        http://www.kongregate.com/games/*
// @author         Ventero
// @license        MIT license
// @version 0.0.1.20160323020800
// ==/UserScript==

// Written by Ventero (http://www.kongregate.com/accounts/Ventero) 05/12/09
// Copyright (c) 2009-2012 Ventero, licensed under MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
// Thanks to Jabor (http://www.kongregate.com/accounts/Jabor) for the idea of adding a prefix!


function init(){
	if(location.href.indexOf("http://www.kongregate.com/games/")==0){
		holodeck.addChatCommand("afk",function (l, n) { if (l._afk == 0) { l._afk = 1; l.activeDialogue().displayMessage("Kong Bot", "You are now flagged as AFK", {class: "whisper received_whisper"}, {non_user: true}); } else {l._afk = 0; l.activeDialogue().displayMessage("Kong Bot", "You aren't flagged as AFK anymore", {class: "whisper received_whisper"}, {non_user: true}); } return false; });

		holodeck.addChatCommand("afkmessage", function (l, n){ var z = n.match(/^\/\S+\s+(.+)/); if (z){a = z[1]}else{a="I am currently AFK"} l._afkmessage = a; l.activeDialogue().displayMessage("Kong Bot", "AFK-message set to: "+a, {class: "whisper received_whisper"}, {non_user: true}); return false});

		holodeck.addChatCommand("afktoggle", function(l, n){ if (l._afktoggle == 0) {l._afktoggle = 1; l.activeDialogue().displayMessage("Kong Bot", "Your AFK-flag won't get removed automatically", {class: "whisper received_whisper"}, {non_user: true})} else {l._afktoggle = 0; l.activeDialogue().displayMessage("Kong Bot", "Your AFK-flag gets removed automatically", {class: "whisper received_whisper"}, {non_user: true})} return false; });

		ChatDialogue.prototype.oldKeyPress = ChatDialogue.prototype.onKeyPress;

		ChatDialogue.prototype.onKeyPress = function (a) { if (a.which == 13) { if(this._holodeck._afktoggle==0 && this._input_node.getValue().indexOf("/afk")!=0){this._holodeck._afk = 0}; this.sendInput(); a.stop(); } else{this.oldKeyPress(a)}};

		ChatDialogue.prototype.receivedPrivateMessage = function (a) { if (a.data.success) { nL=a.data.from;this.displayUnsanitizedMessage(a.data.from, this.sanitizeIncomingMessage(a.data.message) + "&nbsp; (<a class=\"reply_link\" onclick=\"holodeck.insertPrivateMessagePrefixFor('" + a.data.from + "');return false;\" href=\"#\">reply</a>)", {class: "whisper received_whisper"});if(this._holodeck._afk && a.data.message.indexOf(this._holodeck._afkprefix)!=0){this.sendPrivateMessage(a.data.from, this._holodeck._afkprefix+this._holodeck._afkmessage)}; } else { this.displayMessage("Kong Bot", a.data.to + " can not be reached. Please try again later.", {class: "whisper received_whisper"}, {non_user: true}); } };

		holodeck._afk = 0;

		holodeck._afktoggle = 0;

		holodeck._afkmessage = "I am currently AFK";

		holodeck._afkprefix = "[AFK] ";
	}
}

setTimeout(init, 1000);