Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Eka's Chat Convenience Suite
- // @namespace http://tampermonkey.net/
- // @version 0.33
- // @description try to take over the world!
- // @author Sacchi :>
- // @match https://rp.aryion.com/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- function blocklist(){
- //Creates a browser-stored cache of blocked users to allow easy migration between many profiles.
- if (window.location.href.indexOf("page=settings") === -1) return;
- //content.js
- let ignores = localStorage.getItem('ignores');
- if (ignores === null) ignores = "";
- startup({ignores:ignores});
- function startup(data){
- let savebutton = document.createElement("button"); savebutton.innerHTML = "Save Blocklist"; savebutton.classList.add("btn");savebutton.classList.add("btn-default"); savebutton.addEventListener("click", saveBlocks);
- let loadbutton = document.createElement("button"); loadbutton.innerHTML = "Load Blocklist"; loadbutton.classList.add("btn");loadbutton.classList.add("btn-default"); loadbutton.addEventListener("click", loadBlocks);
- let roster = document.createElement("div"); roster.setAttribute("style", "margin-top:1em"); roster.setAttribute("id", "blocklist");
- let inputarea = document.createElement("form"); let textfield = document.createElement("input"); textfield.setAttribute("type", "text"); textfield.setAttribute("id", "blockentry");textfield.setAttribute("style", "color:black;");
- let fieldbutton = document.createElement("button"); fieldbutton.innerHTML = "Input Blocklist from Text"; fieldbutton.classList.add("btn");fieldbutton.classList.add("btn-default"); fieldbutton.addEventListener("click", loadFromText);
- textfield.updateText = function(data){
- this.value = data.toString();
- }
- textfield.updateText(data.ignores);
- inputarea.appendChild(textfield);
- let nav = document.getElementById("char-settings").getElementsByClassName("form-group")[2];
- nav.appendChild(savebutton);
- nav.appendChild(loadbutton);
- nav.appendChild(roster);
- nav.appendChild(inputarea);
- nav.appendChild(fieldbutton);
- updateBlocklist(data.ignores);
- }
- function loadBlocks(){
- let ignores = localStorage.getItem('ignores');
- let container = document.getElementById("persistIgnore");
- let tagbox = document.getElementsByClassName("bootstrap-tagsinput")[1];
- let span = "";
- updateIgnoreBox(ignores);
- alert("Successfully loaded blocklist. Please press Save for it to take effect.")
- }
- function saveBlocks(){
- let users = new Set();
- let list = document.getElementById("persistIgnore").getElementsByTagName("option");
- for (let user = 0; user<list.length; user++){
- let name = list[user].textContent;
- users.add(name);
- }
- users = Array.from(users);
- updateBlocklist(users);
- console.log(users);
- localStorage.setItem('ignores', users);
- }
- function updateIgnoreBox(ignores){
- if (typeof ignores === 'string'){
- ignores = ignores.split(",");
- }
- let container = document.getElementById("persistIgnore");
- let tagbox = document.getElementsByClassName("bootstrap-tagsinput")[1];
- let block = document.getElementById("blockentry");
- let finished = "";
- let span="";
- for (let i=0;i<ignores.length;i++){
- finished += `<option selected="selected">${ignores[i]}</option>`;
- finished += `<option selected="selected" value="${ignores[i]}">${ignores[i]}</option>`;
- span += `<span class="tag label label-info">${ignores[i]}<span data-role="remove"></span></span>`;
- }
- tagbox.innerHTML = span + `<input size="1" type="text" placeholder="">`;
- container.innerHTML = finished;
- }
- function loadFromText(){
- let block = document.getElementById("blockentry");
- if (block.value.length < 1) return;
- let ignores = block.value.split(",");
- if (ignores.length < 1) return;
- let container = document.getElementById("persistIgnore");
- for (let ignore in ignores){
- ignores[ignore] = ignores[ignore].trim();
- }
- updateIgnoreBox(ignores);
- let users = Array.from(new Set(ignores));
- localStorage.setItem('ignores', users);
- alert("Successfully loaded from text. Please press Save.")
- }
- function updateBlocklist(data){
- let blocklist = document.getElementById("blocklist");
- let str = "";
- if (typeof data === 'string'){
- data = data.split(",");
- }
- for (let i=0;i<data.length;i++){
- str += `${i+1}: ${data[i]} || `;
- }
- blocklist.innerHTML = `Your blocklist currently contains: <b>${str}</b>`;
- }
- };
- function pingStopper(){
- //Makes it so you no longer recieve a 'ping' when a blocked user messages or mentions you.
- if (window.location.href.indexOf("jchat.srv") === -1) return;
- if (typeof handleChatMessage == "undefined") return;
- handleChatMessage = function (msg){
- var $msg = renderChatMessage(msg);
- // Open hoverboxes automatically if settings say to do so.
- if (me.settings.autoHoverWhispers && msg.type === "WHISPER_CHAT") {
- if (msg.fromMe) {
- HoverBoxSystem({leash: msg.to.name, type: "whisper", title: msg.to.name}).create();
- } else {
- HoverBoxSystem({leash: msg.from.name, type: "whisper", title: msg.from.name}).create();
- }
- }
- else if (me.settings.autoHoverGroups && msg.type === "GROUP_CHAT") {
- HoverBoxSystem({leash: msg.toLeash, type: "groupchat", title: msg.to.name}).create();
- }
- HoverBoxSystem.routeToPane($msg);
- // Play sound if necessary
- if (!ses.ignored[msg.from.id]) {
- if (msg.fromMe === false && msg.type === "WHISPER_CHAT") {
- if (me.settings.enableSound && sounds.whisper) sounds.whisper.play();
- }
- else if ($msg.hasClass("highlight")) {
- if (me.settings.enableSound && sounds.highlighted) sounds.highlighted.play();
- }
- else if ($msg.hasClass("nameding")) {
- if (me.settings.enableSound && sounds.nameding) sounds.nameding.play();
- }
- else if (msg.fromMe === false) {
- if (me.settings.enableSound && sounds.received) sounds.received.play();
- }
- }
- // Add the title alert if window is not focused.
- if (window.isFocused === false
- && ($msg.hasClass("highlight") || $msg.hasClass("nameding"))
- && document.title.substr(0, TITLE_ALERT.length) !== TITLE_ALERT) {
- document.title = TITLE_ALERT + document.title;
- }
- }
- }
- function profileEditFix(){
- //Removes the horizontal scroll bars that appear in the profile edit screen which can make editing profiles much more difficult.
- if (window.location.href.indexOf("page=profile") === -1) return;
- const sty = document.createElement("style");
- sty.textContent = `pre{overflow:hidden;}`;
- document.head.append(sty);
- }
- function extraEyecons(){
- //Allows a user to have a total of 8 eyecons on a character. Takes effect permanently on that character once a profile is saved.
- if (window.location.href.indexOf("page=profile") === -1) return;
- let vals = Array.from(document.getElementById("char-main").getElementsByTagName("input"));
- let cid = vals[0].value;
- let csrf = vals[1].value;
- const eyeconContainer = document.getElementById("char-favcolors");
- const eyeconList = Array.from(eyeconContainer.getElementsByTagName("ol"))[0];
- const eyecons = eyeconList.getElementsByTagName("li");
- function createNewEyecon(num){
- /**let template = `
- <input type="hidden" name="fc.id" value="${num}">
- <div class="form-group ">
- <label for="fc${num}-color">Color:</label>
- <div class="input-group input-group-sm">
- <span class="input-group-addon color-sample" id="fc${num}-cs" style="color: #ffffff;">Lorem ipsum dolor sit amet</span>
- <input id="fc${num}-color" type="text" name="fc.textColor" value="#ffffff" data-target="#fc${num}-cs" class="colorpicker form-control input-sm" style="width: 80px;" autocomplete="off" data-original-title="" title="">
- </div>
- </div>
- <div class="form-group">
- <label for="fc${num}-eyecon-file">Eyecon:</label>
- <input type="hidden" name="fc.eyecon" value="">
- <div class="btn btn-default btn-file btn-sm">
- <span>Browse</span>
- <input class="form-control input-sm" type="file" name="neweyecon" autocomplete="off" data-toggle="autocropper" data-modal="show" data-target="#modal-auto-cropper" data-linked-image="#fc${num}-eyecon-img" data-max-thumb-width="50" data-max-thumb-height="25" data-form-action="profileEdit.srv?action=saveFavcolorEyecon" data-form-data="{"cid":${cid}, "csrf":"${csrf}", "fc.id":"${num}"}">
- </div>
- <span>
- <img id="fc${num}-eyecon-img" src="">
- <a class="clear-eyecon" href="#" title="Clear Eyecon">×</a>
- </span>
- </div>
- `;**/
- let template = `
- <input type="hidden" name="fc.id" value="${num}">
- <div class="form-group ">
- <label for="fc${num}-color">Color:</label>
- <div class="input-group input-group-sm">
- <span class="input-group-addon color-sample" id="fc4-cs" style="color: #ffffff;">Lorem ipsum dolor sit amet</span>
- <input id="fc$4-color" type="text" name="fc.textColor" value="#ffffff" data-target="#fc${num}-cs" class="colorpicker form-control input-sm" style="width: 80px;" autocomplete="off" data-original-title="" title="">
- </div>
- </div>
- <div class="form-group">
- <label for="fc1-eyecon-file">Eyecon:</label>
- <input type="hidden" name="fc.eyecon" value="4">
- <div class="btn btn-default btn-file btn-sm">
- <span>Browse</span>
- <input class="form-control input-sm" type="file" name="neweyecon" autocomplete="off" data-toggle="autocropper" data-modal="show" data-target="#modal-auto-cropper" data-linked-image="#fc${num}-eyecon-img" data-max-thumb-width="50" data-max-thumb-height="25" data-form-action="profileEdit.srv?action=saveFavcolorEyecon" data-form-data="{"cid":${cid}, "csrf":"${csrf}", "fc.id":"4"}">
- </div>
- <span style="display: none;">
- <img id="fc${num}-eyecon-img">
- <a class="clear-eyecon" href="#" title="Clear Eyecon">×</a>
- </span>
- </div>
- `;
- let element = document.createElement("li");
- element.innerHTML = template.trim();
- let d = document.createElement("li");
- d.id="fc"+num;
- d.setAttribute("style","margin-bottom: 12px;");
- element.childNodes.forEach((x)=>d.appendChild(x));
- eyeconList.appendChild(d);
- }
- if (document.getElementById("fc5") === null){
- createNewEyecon(5);
- }
- if (document.getElementById("fc6") === null){
- createNewEyecon(6);
- }
- if (document.getElementById("fc7") === null){
- createNewEyecon(7);
- }
- if (document.getElementById("fc8") === null){
- createNewEyecon(8);
- }
- }
- function tempAllListFixer(){
- //Fixes text cutoff on the temporary all list plus small improvements to layout.
- if (window.location.href.indexOf("userlist.srv") === -1) return;
- let style = document.createElement("style");
- style.textContent = `.ul-tile p.summary{overflow-y:scroll;} .ul-tile p.summary::-webkit-scrollbar{width:12px;} .ul-tile p.summary::-webkit-scrollbar-track{background-color:white;border-radius:4px;} .ul-tile p.summary::-webkit-scrollbar-thumb{background-color:#6f40bf;border-radius:3px;}`;
- document.head.appendChild(style);
- }
- function privateLogFilterModule(){
- //DATE: 09/05/2020
- //This module is designed to only take effect on the private logs menu. This module allows you to click a name to only show messages between you and that user.
- if (window.location.href.indexOf("privlog.srv") === -1) return;
- //Initial setup to prevent clickthrough to child elements.
- let s = document.createElement("style");
- s.innerText = ".log-name *{pointer-events:none}#download-log-link{display:block;margin-left:auto;margin-right:auto;text-align:center;font-weight:bold;font-size:150%;}";
- document.head.appendChild(s);
- //Initial setup to create log downloader button.
- let leftBar = document.querySelector("#left");
- let downloadButton = document.createElement("a");
- downloadButton.id = "download-log-link";
- downloadButton.innerText = `Download currently displayed log.`;
- downloadButton.download = "log";
- downloadButton.style.border = "4px solid #ac34a5";
- downloadButton.style.borderRadius = "10px";
- downloadButton.style.cursor = "pointer";
- leftBar.prepend(downloadButton);
- let filterByName = function(searchingName){
- let msgs = document.querySelector("#main").querySelectorAll(".chatmsg");
- for (let i=0;i<msgs.length;i++){
- if (msgs[i].children[1].innerText != searchingName && msgs[i].children[2].innerText != searchingName){
- msgs[i].style.display = "None";
- }else{
- msgs[i].style.display = "Block";
- }
- }
- }
- //Event listener added to body instead of individual nodes. Since nodes are created after AJAX requests, no easy way to add onclicks without modifying native code.
- document.body.addEventListener("click", function(event){
- if(event.srcElement.classList.contains("log-name")) {
- let name = event.srcElement.getElementsByTagName("span")[1].innerText;
- filterByName(name);
- };
- let text = document.querySelector("#main").innerText;
- let file = window.URL.createObjectURL(new Blob([text],{type: 'text/plain'}));
- downloadButton.href = file;
- });
- }
- function pingHighlighter(){
- //Date: 09/05/2020
- //This module is fairly simple. All it does is changes the background color of any alias-ping
- //messages on chat to make them easier to spot.
- if (window.location.href.indexOf("jchat.srv") === -1) return;
- let s = document.createElement("style");
- s.innerText = ".nameding{background-color:#222222}";
- document.head.appendChild(s);
- }
- //If for any reason you would prefer to not have a module, you can remove it by commenting it out down below here.
- //All modules are completely independent so nothing should break.
- blocklist();
- pingStopper();
- profileEditFix();
- extraEyecons();
- tempAllListFixer();
- privateLogFilterModule();
- pingHighlighter();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement