您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script is just amazing! Check the script for some configs!
当前为
- // ==UserScript==
- // @name RainbowChat for DH1
- // @namespace http://tampermonkey.net/
- // @version 1.0.0
- // @description This script is just amazing! Check the script for some configs!
- // @author Lasse98brus
- // @match http://www.diamondhunt.co/DH1/game.php
- // @run-at document-idle
- // @grant none
- // ==/UserScript==
- /* jshint -W097 */
- 'use strict';
- /*
- * #=================================================================================================================================================================================================#
- * # Welcome to my RainbowChat script for both DH1 and DH2 :D My name is Lasse98brus and I did create this script because Amyjane1991 said she had the old DHRainbowChat that doesn't work anymore! #
- * # I pretty much had to change the whole script! So please don't this with the original DHRainbowChat! This script is built to be as stable as possible! #
- * # #
- * # If you like my script and my work with it, and you feel to support my work! Feel free to donate to me with PayPal :D my PayPal: lasse.brustad@gmail.com #
- * #=================================================================================================================================================================================================#
- */
- // Some configs to easily choose the futures that YOU like! :D
- var config = {
- // Here you can just change between "true" and "false" before you login to the game! :)
- "rainbowTime" : false, // Set to "true" to enable rainbow timestamps! This will color timestamps for server messages too (default: "false")
- "rainbowName" : true, // Set to "false" to disable rainbow names! (default: "true")
- "removeIcons" : false, // Set to "true" to remove all icons in chat, doesn't remove donor icon! (default: "false")
- // Futures under here does have multiple choises! Read the end of the lines to know whats working ad not!
- // Unfortunately it's nothing to configure here yet!
- // Uder development! Something isn't working as well!
- "rainbowMSG" : false // Under development! This works pretty good! Links doesn't work because of this for now! (default: "false")
- };
- /*
- * #=================#
- * # Update history! #
- * #=================#
- *
- * v1.0.0 - February 19th 2017
- * + Initial release! :D
- *
- * v1.x.x - Comming soon!
- * ? Try to fix "rainbowMSG" to support links!
- * ? Maybe adding choises of color sets?
- * ? Adding more color choises in the config!
- *
- */
- /*
- * #======================================================================================================================#
- * # I'm pretty sure you don't need to change anything below here! It's pretty much fully customizeable in the configs :) #
- * #======================================================================================================================#
- */
- document.getElementById("chat-area-div").style = "background-color:#0c0c0c;color:#999!important;"; // Please just let this be! this makes the chat look a lot better with the colors used in this script!
- var rcColours = [
- ["#ff0000", "#cc0000", "#b30000"], // Red colors
- ["#00cc00", "#009900", "#00e600"], // Green colors
- ["#ff99cc", "#ff4da6", "#ff0080"], // Pink colors
- ["#9900cc", "#730099", "#bf00ff"], // Purple colors
- ["#ff9933", "#ff8000", "#ff9933"], // Orange colors
- ["#e6b800", "#cca300", "#b38f00"] // Gold/Yellow colors
- ];
- var rcColour = -1;
- var rcLastColour = -1;
- // This is a trigger for the script to make the changes!
- window.refreshChat = function(data) {
- data = newRainbowChat(data);
- };
- // The actually magically code is here! This code will make the chat colors change when the above code is triggered and need this code!
- // All errors here that Tampermonkey tell you "'someVar' is not defined." is allready in Smitty's scripts!
- function newRainbowChat(data) {
- var chatbox = document.getElementById("chat-area-div");
- var output = data;
- var splitArray = data.split("~");
- var userChatting = splitArray[0];
- var levelChat = splitArray[1];
- var tag = splitArray[2];
- var icon = splitArray[3];
- var message = splitArray[4];
- var isPM = splitArray[5];
- for(var i = 0; i < mutedPeople.length; i++) { if(mutedPeople[i] == userChatting) return; }
- var chatSegment = "";
- // Random color!
- while (rcColour === rcLastColour) { rcColour = getRandomArbitrary(0, rcColours.length); }
- rcLastColour = rcColour;
- var myColour = rcColours[rcColour][getRandomArbitrary(0, rcColours[rcColour].length)];
- var msg = "";
- if(config.rainbowMSG === true) {
- msg = "<span style='color:" + myColour + "'>" + message + "</span>";
- } else {
- msg = message;
- }
- var timeStamp = "";
- if(config.rainbowTime === true) {
- timeStamp = "<span style='color:" + myColour + "'>" + timeFetch() + "</span>";
- } else {
- timeStamp = timeFetch();
- }
- var totalTextDiv = "";
- if(isPM == 1)
- {
- chatSegment = "<span style='color:purple'>PM from " + "<span style='cursor:pointer;' oncontextmenu='searchPlayerHicores(\""+userChatting+"\");return false;' onclick='preparePM(\""+userChatting+"\")'>"+userChatting+"</span>" +": " + message + "</span>";
- chatSegment += "<br />";
- lastPMFrom = userChatting;
- totalTextDiv = chatbox.innerHTML + timeStamp + chatSegment;
- chatbox.innerHTML = totalTextDiv;
- if(isAutoScrolling) { $("#chat-area-div").animate({ scrollTop: 55555555 }, 'slow'); }
- return;
- }
- if(isPM == 2)
- {
- chatSegment = "<span style='color:purple'>sent PM to " + "<span style='cursor:pointer;' oncontextmenu='searchPlayerHicores(\""+userChatting+"\");return false;' onclick='preparePM(\""+userChatting+"\")'>"+userChatting+"</span>" +": " + message + "</span>";
- chatSegment += "<br />";
- totalTextDiv = chatbox.innerHTML + timeStamp + chatSegment;
- lastPMFrom = userChatting;
- chatbox.innerHTML = totalTextDiv;
- if(isAutoScrolling) { $("#chat-area-div").animate({ scrollTop: 55555555 }, 'slow'); }
- return;
- }
- if(isPM == 3) //yell message
- {
- chatSegment = "<span style='color:#0066ff;'><span class='chat-tag-yell'>Server Message</span> " + message + " </span>";
- chatSegment += "<br />";
- totalTextDiv = chatbox.innerHTML + timeStamp + chatSegment;
- lastPMFrom = userChatting;
- chatbox.innerHTML = totalTextDiv;
- if(isAutoScrolling) { $("#chat-area-div").animate({ scrollTop: 55555555 }, 'slow'); }
- return;
- }
- if(config.removeIcons === false) {
- if(icon == 1) { chatSegment = "<img title='Maxed Skills' src='images/icons/stats.png' style='vertical-align: text-top;' width='20' height='20' alt='Maxed Skills'/>" + chatSegment;
- } else if(icon == 2) { chatSegment = "<img title='Master in Mining' src='images/icons/pickaxe.png' style='vertical-align: text-top;' width='20' height='20' alt='Master in Mining'/>" + chatSegment;
- } else if(icon == 3) { chatSegment = "<img title='Master in Crafting' src='images/icons/anvil.png' style='vertical-align: text-top;' width='20' height='20' alt='Master in Crafting'/>" + chatSegment;
- } else if(icon == 4) { chatSegment = "<img title='Master in Brewing' src='images/brewing/vialofwater_chat.png' style='vertical-align: text-top;' width='20' height='20' alt='Master in Brewinghiscores'/>" + chatSegment;
- } else if(icon == 5) { chatSegment = "<img title='Master in Farming' src='images/icons/watering-can.png' style='vertical-align: text-top;' width='20' height='20' alt='Master in Farming'/>" + chatSegment;
- } else if(icon == 6) { chatSegment = "<img title='Hardcore Account' src='images/icons/hardcoreIcon.png' style='vertical-align: text-top;' width='20' height='20' alt='Hardcore Account'/>" + chatSegment;
- } else if(icon == 7) { chatSegment = "<img title='Halloween 2015' src='images/icons/halloween2015.png' style='vertical-align: text-top;' width='20' height='20' alt='Halloween 2015'/>" + chatSegment;
- } else if(icon == 8) { chatSegment = "<img title='Halloween 2015' src='images/icons/archaeology.png' style='vertical-align: text-top;' width='20' height='20' alt='Halloween 2015'/>" + chatSegment;
- } else if(icon == 9) { chatSegment = "<img title='Chirstmas 2015' src='images/sigils/christmas2015.png' style='vertical-align: text-top;' width='20' height='20' alt='Halloween 2015'/>" + chatSegment;
- } else if(icon == 10) { chatSegment = "<img title='Master in Farming' src='images/magic/wizardHatIcon.png' style='vertical-align: text-top;' width='20' height='20' alt='Master in Farming'/>" + chatSegment;
- } else if(icon == 11) { chatSegment = "<img title='Holiday' src='images/sigils/easter2016.png' style='vertical-align: text-top;' width='20' height='20' alt='Holiday Sigil'/>" + chatSegment;
- } else if(icon == 12) { chatSegment = "<img title='COOP' src='images/icons/groupTaskBadge5.png' style='vertical-align: text-top;' width='20' height='20' alt='COOP'/>" + chatSegment;
- } else if(icon == 13) { chatSegment = "<img title='cooking master' src='images/icons/cookingskill.png' style='vertical-align: text-top;' width='20' height='20' alt='Cooking Master'/>" + chatSegment;
- } else if(icon == 14) { chatSegment = "<img title='Halloween 2016' src='images/sigils/halloween2016.png' style='vertical-align: text-top;' width='20' height='20' alt='Halloween 2016'/>" + chatSegment;
- } else if(icon == 15) { chatSegment = "<img title='Chirstmas 2016' src='images/sigils/christmas2016.png' style='vertical-align: text-top;' width='20' height='20' alt='Christmas 2016'/>" + chatSegment; }
- } // End of "removeIcons"
- if(tag == 1) { chatSegment += "<span><img src='images/icons/donor-icon.gif' style='vertical-align: text-top;' width='20' height='20' alt='Donor'/> ";
- } else if(tag == 2) { chatSegment += "<span style='color:green;'><span class='chat-tag-contributor'>Contributor</span> ";
- } else if(tag == 4) { chatSegment += "<span style='color:#669999;'><span class='chat-tag-mod'>Moderator</span> ";
- } else if(tag == 5) { chatSegment += "<span style='color:#666600;'><span class='chat-tag-dev'>Dev</span> "; }
- if(config.rainbowName === true) { chatSegment += "<span style='cursor:pointer;color:" + myColour + "' oncontextmenu='searchPlayerHicores(\"" + userChatting + "\");return false;' onclick='preparePM(\"" + userChatting + "\")'>" + userChatting + " (" + levelChat +"): </span>";
- } else { chatSegment += "<span style='cursor:pointer' oncontextmenu='searchPlayerHicores(\"" + userChatting + "\");return false;' onclick='preparePM(\"" + userChatting + "\")'>" + userChatting + " (" + levelChat +"): </span>"; }
- //make links clickable
- if(isValidURL(msg) && disableUrls === 0) {
- var msgArray = msg.split(" ");
- var newString = "";
- var linkFound = "";
- for(i = 0; i < msgArray.length; i++) {
- if(isValidURL(msgArray[i])) {
- if(!msgArray[i].startsWith("http")) { linkFound = "<a style='color:#40ff00' href='http://"+msgArray[i]+"' target='_blank'>"+msgArray[i]+"</a>" + " ";
- } else { linkFound = "<a style='color:#40ff00' href='"+msgArray[i]+"' target='_blank'>"+msgArray[i]+"</a>" + " "; }
- newString += linkFound;
- } else { newString += msgArray[i] + " "; }
- }
- chatSegment += newString;
- } else { chatSegment += msg; }
- chatSegment += "<span><br />";
- totalTextDiv = chatbox.innerHTML + timeStamp + chatSegment;
- chatbox.innerHTML = totalTextDiv;
- if(isAutoScrolling) { $("#chat-area-div").animate({ scrollTop: 55555555 }, 'slow'); }
- return data;
- }
- function getRandomArbitrary(min, max) {
- return Math.floor(Math.random() * (max - min) + min);
- }