Advertisement
Degritone

BBS Non-Colorful Chatroom

Oct 30th, 2021 (edited)
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name             BBS Non-Colorful Chatroom
  3. // @namespace        dollars-bbs.org
  4. // @author           Degritone
  5. // @description      Adds back in limited functionality for the chatroom for the Dollars BBS
  6. // @match            *://*.dollars-bbs.org/*
  7. // @match            *://qchat.rizon.net/*
  8. // @grant            none
  9. // ==/UserScript==
  10.  
  11. function request(url){
  12.   let xmlHttp = new XMLHttpRequest();
  13.   xmlHttp.open("GET",url,false);
  14.   xmlHttp.send(null);
  15.   return xmlHttp.responseText;
  16. }
  17.  
  18. let icons = [];
  19.  
  20. if(window.location.href.startsWith("https://dollars-bbs.org/chatroom")){
  21.   document.title = "Dollars BBS | Chatroom";
  22.   window.location.href = "https://qchat.rizon.net";
  23. } if(window.location.href.startsWith("https://dollars-bbs.org")){
  24.   chatLink();
  25. } else if(window.location.href.startsWith("https://qchat.rizon.net")){
  26.   document.title = "Dollars BBS | Chatroom";
  27.   setTimeout(checkForLoaded,100);
  28.   getIcons();
  29. }
  30.  
  31. function getIcons(){
  32.   for(let i=0;i<117;i++){
  33.     let image = "https://ia601408.us.archive.org/13/items/drrr-like-chat-icons/"+i+".png";
  34.     let icon = document.createElement("img");
  35.     icon.src = image;
  36.     icon.style.width = "58px";
  37.     icon.style.margin = "auto";
  38.     icon.width = 58;
  39.     icon.height = 58;
  40.     icon.setAttribute("class","drrrIcon");
  41.     icon.onload = function(){icons[i] = icon;iconLoader();icon.setAttribute("isLoaded",true);};
  42.     icon.onerror = function(){finishedLoading();};
  43.   }
  44. }
  45.  
  46. function chatLink(){
  47.   let menu = document.getElementById("pagemenu");
  48.   if(!menu){
  49.     setTimeout(chatLink,100);
  50.     return;
  51.   }
  52.   let chatroom = document.createElement("li");
  53.   chatroom.innerHTML = "<a href='https://dollars-bbs.org/chatroom'>Chatroom</a>";
  54.   menu.children[2].children[0].innerHTML = "Other Chats";
  55.   menu.insertBefore(chatroom,menu.children[2]);
  56. }
  57.  
  58. function checkForLoaded(){
  59.   let loaded = document.getElementsByClassName("tr2").length;
  60.   if(!(loaded>0))
  61.     setTimeout(checkForLoaded,100);
  62.   else{
  63.     setTimeout(login,100);
  64.   }
  65. }
  66.  
  67. function login(){
  68.   document.title = "Dollars BBS | Chatroom";
  69.  
  70.   let topNode = document.getElementsByClassName("dynamicpanel qwebirc-qui topboundpanel outertabbar outertabbar_top")[0];
  71.   topNode.parentNode.removeChild(topNode);
  72.  
  73.   let favicon = document.createElement("link");
  74.   favicon.href = "https://dollars-bbs.org/random/favicon.ico";
  75.   favicon.rel = "shortcut icon";
  76.   document.head.appendChild(favicon);
  77.  
  78.   let bg = document.getElementsByClassName("dynamicpanel qwebirc-qui middleboundpanel lines")[0];
  79.   bg.style.background = "#000000";
  80.   bg.style.color = "#DDDDDD";
  81.   bg.style.top = "0px";
  82.   bg.style.bottom = "0px";
  83.   bg.style.left = "0px";
  84.   bg.style.right = "0px";
  85.   bg.style.height = "";
  86.  
  87.   let form = document.getElementsByTagName("table")[1];
  88.   form.style.top = "0px";
  89.   form.style.left = "50%";
  90.   form.style.transform = "translateX(-50%)";
  91.   form.style.position = "absolute";
  92.   form.children[0].removeChild(form.children[0].children[0]);
  93.  
  94.   let startButton = document.getElementsByTagName("input");
  95.   for(let i=0;i<startButton.length;i++){
  96.     if(startButton[i].value == "Connect"){
  97.       startButton = startButton[i];
  98.       break;
  99.     }
  100.   }
  101.   startButton.style.width = "148px";
  102.   startButton.onclick = ()=>waitForChat(false,document.getElementsByTagName("input")[0].value);
  103.  
  104.   inputs();
  105. }
  106.  
  107. function iconLoader(){
  108.   let name = document.getElementsByTagName("input")[0];
  109.   let bg = document.getElementsByClassName("dynamicpanel qwebirc-qui middleboundpanel lines")[0];
  110.   let iconHolder = document.getElementById("iconHolder");
  111.   if(!iconHolder){
  112.     iconHolder = document.createElement("div");
  113.     bg.appendChild(iconHolder);
  114.     iconHolder.id = "iconHolder";
  115.     iconHolder.style.width = (13*60)+"px";
  116.     iconHolder.style.position = "absolute";
  117.     iconHolder.style.top = "112px";
  118.     iconHolder.style.left = "50%";
  119.     iconHolder.style.transform = "translateX(-50%)";
  120.     iconHolder.style.display = "flex";
  121.     iconHolder.style.flexWrap = "wrap";
  122.     iconHolder.style.flexDirection = "row";
  123.     iconHolder.style.justifyContent = "center";
  124.   }
  125.   let start = 0;
  126.   if(name.value.match(/^\[[0-9]+\]/))
  127.     start = parseInt(name.value.replace("[","").replace(/\].+/,""));
  128.   for(let i=iconHolder.children.length;i<icons.length;i++){
  129.     let selection = document.createElement("div");
  130.     selection.style.width = "60px";
  131.     selection.style.height = "75px";
  132.     selection.style.display = "inline-block";
  133.     selection.style.position = "relative";
  134.     selection.style.margin = "0px";
  135.     selection.style.alignSelf = "center";
  136.  
  137.     let radio = document.createElement("input");
  138.     radio.type = "radio";
  139.     radio.id = "icon"+i;
  140.     radio.name = "icon";
  141.     radio.value = i;
  142.     radio.style.left = "23px";
  143.     radio.style.bottom = "2px";
  144.     radio.style.position = "absolute";
  145.     radio.style.margin = "0px";
  146.     if(i==start)
  147.       radio.checked = "checked";
  148.  
  149.     let label = document.createElement("label");
  150.     label.htmlFor = "icon"+i;
  151.  
  152.     let icon = document.createElement("img");
  153.     label.appendChild(icon);
  154.     icon.outerHTML = icons[i].outerHTML;
  155.     selection.appendChild(label);
  156.     selection.appendChild(radio);
  157.     selection.onclick = ()=>adjustName();
  158.  
  159.     iconHolder.appendChild(selection);
  160.   }
  161.   inputs();
  162. }
  163.  
  164. function inputs(){
  165.   let nameInput = document.getElementsByTagName("input")[0];
  166.   if(nameInput.value == ""){
  167.     let cookies = document.cookie.split(";");
  168.     for(let i=0;i<cookies.length;i++){
  169.       let pair = cookies[i].split("=");
  170.       if(pair[0]==" name")
  171.         nameInput.value = pair[1];
  172.     }
  173.   }
  174.  
  175.   if(!document.getElementById("typingName")){
  176.     let name = document.createElement("input");
  177.     name.autocomplete = "off";
  178.     name.autocorrect = "off";
  179.     name.autocapitalize = "off";
  180.     name.spellcheck = false;
  181.     name.style = window.getComputedStyle(nameInput);
  182.     name.id = "typingName";
  183.     name.value = nameInput.value.replace(/\[[0-9]+\]/,"");
  184.     name.oninput = ()=>adjustName();
  185.     nameInput.parentNode.appendChild(name);
  186.   }
  187.   nameInput.style.display = "none";
  188.  
  189.   let channelInput = document.getElementsByTagName("input")[2];
  190.   channelInput.value = "#dollars-bbs";
  191.   channelInput.parentNode.parentNode.style.display = "none";
  192.  
  193.   let iconHolder = document.getElementById("iconHolder");
  194.   if(iconHolder){
  195.     let w = Math.ceil(icons.length/Math.floor((window.innerHeight-parseInt(iconHolder.style.top.replace("px","")))/75))*60;
  196.     iconHolder.style.width = w+"px";
  197.   }
  198. }
  199.  
  200. let ownName = "";
  201.  
  202. function adjustName(){
  203.   let name = document.getElementsByTagName("input")[0];
  204.   let radios = document.getElementsByName("icon");
  205.   let value = 0;
  206.   for(let i=0;i<radios.length;i++){
  207.     if(radios[i].checked){
  208.       value = radios[i].value
  209.       break;
  210.     }
  211.   }
  212.  
  213.   name.value = "["+value+"]"+document.getElementById("typingName").value;
  214.   name.dispatchEvent(new Event("input"));
  215.   ownName = name.value;
  216. }
  217.  
  218. function waitForChat(once=false,name=""){
  219.   if(!once){
  220.     once = true;
  221.     let cover = document.createElement("div");
  222.     cover.id = "loadingCover";
  223.     cover.style.position = "fixed";
  224.     cover.style.top = "0px";
  225.     cover.style.bottom = "0px";
  226.     cover.style.left = "0px";
  227.     cover.style.right = "0px";
  228.     cover.style.background = "#000000";
  229.     cover.style.color = "#FFFFFF";
  230.     cover.innerHTML = "LOADING";
  231.     document.body.appendChild(cover);
  232.     let date = new Date();
  233.     date.setTime(date.getTime()+(1000*60*60*24*365));
  234.     document.cookie = "name="+name+"; expires="+encodeURIComponent(date.toUTCString())+";";
  235.     ownName = name;
  236.   }
  237.   if(document.getElementsByClassName("nicklist tab-invisible dynamicpanel qwebirc-qui rightboundpanel").length<1){
  238.     setTimeout(waitForChat,100,once);
  239.     return;
  240.   }
  241.   chat(false,false);
  242. }
  243.  
  244. function chat(once,loaded){
  245.   if(!(document.getElementsByClassName("dynamicpanel qwebirc-qui topicboundpanel topic tab-invisible colourline")[0] || document.getElementsByTagName("input")[0]) && !once){
  246.     setTimeout(chat,100,false,false);
  247.     return;
  248.   }
  249.   if(!loaded){
  250.     setTimeout(chat,100,false,true);
  251.     document.body.removeChild(document.getElementById("loadingCover"));
  252.     return;
  253.   }
  254.   setTimeout(chat,100,true,true);
  255.   let input = document.getElementsByClassName("dynamicpanel qwebirc-qui bottomboundpanel input")[0];
  256.   input.style.position = "relative";
  257.   input.style.top = "0px";
  258.  
  259.  
  260.   let messageList = document.getElementsByClassName("dynamicpanel qwebirc-qui middleboundpanel lines ircwindow")[0];
  261.   if(!messageList)
  262.     messageList = document.getElementsByClassName("drrrMessageList")[0];
  263.   messageList.style.background = "rgba(0,0,0,1)";
  264.   messageList.style.width = "100%";
  265.   messageList.style.overflowY = "scroll";
  266.   messageList.style.overflowX = "hidden";
  267.   messageList.style.bottom = "0px";
  268.   messageList.style.top = window.getComputedStyle(input).height;
  269.   messageList.style.position = "fixed";
  270.   messageList.parentNode.top = "100px";
  271.   let messages = messageList.getElementsByClassName("colourline");
  272.   if(messages.length<1)
  273.     return;
  274.  
  275.   for(let i=0;i<messages.length;i++){
  276.     let slashMe = 0;
  277.     let spans = messages[i].getElementsByTagName("span");
  278.     if(spans.length<4){
  279.       if(spans.length<3 || !spans[1].innerHTML.startsWith(" * ")){
  280.         continue;
  281.       }
  282.       slashMe = 1;
  283.     }
  284.    
  285.     let reply = document.createElement("div");
  286.     reply.setAttribute("class","drrrReply");
  287.     reply.style.width = (600+58+25)+"px";
  288.     reply.style.margin = "auto";
  289.     let personHolder = document.createElement("div");
  290.     personHolder.style.width = "58px";
  291.     personHolder.style.position = "relative";
  292.     personHolder.style.display = "flex";
  293.     reply.appendChild(personHolder);
  294.     let replyHolder = document.createElement("div");
  295.     replyHolder.style.width = "600px";
  296.     replyHolder.style.display = "flex";
  297.     let replyBubble = document.createElement("div");
  298.     replyBubble.style.alignSelf = "center";
  299.     replyBubble.style.display = "flex";
  300.     let replyText = document.createElement("div");
  301.     replyText.style.display = "flex";
  302.     replyBubble.appendChild(replyText);
  303.     replyHolder.appendChild(replyBubble);
  304.     reply.appendChild(replyHolder);
  305.     messageList.prepend(reply);
  306.    
  307.     let name = "";
  308.     if(messages[i].getElementsByClassName("hyperlink-whois"))
  309.       name = messages[i].getElementsByClassName("hyperlink-whois")[0];
  310.     else
  311.       name = spans[3-slashMe];
  312.     let self = name.parentNode.getAttribute("class") == "Xu";
  313.     name = name.innerHTML;
  314.     let pm = spans[1];
  315.     let m = spans[2+(self?2:0)-slashMe].innerHTML;
  316.     if(m == "@")
  317.       m = spans[3+(self?2:0)-slashMe].innerHTML;
  318.     if(self)
  319.       m = m.replace(/^&gt; /,"");
  320.     else if(!slashMe)
  321.       m = m.replace(/.+?&gt; /,"");
  322.     else
  323.       m = m.replace(/.+<\/span> /,"");
  324.     replyText.innerHTML = "<span style='overflow-wrap: break-word; width: 100%;'>"+m+"</span>";
  325.     let id = 0;
  326.     let nameheight = 0;
  327.  
  328.     let iconHolder = document.createElement("div");
  329.     personHolder.appendChild(iconHolder);
  330.     if(name.match(/^@?\[[0-9]+\]/)){
  331.       id = parseInt(name.replace(/@?\[/,"").replace(/\].+/,""));
  332.     }
  333.  
  334.     if(!icons[id])
  335.       setIcon(0,iconHolder);
  336.     else
  337.       setIcon(id,iconHolder);
  338.  
  339.     let namePlate = document.createElement("div");
  340.     namePlate.innerHTML = name.replace(/\[[0-9]+\]/,"");
  341.     namePlate.style.margin = "auto";
  342.     namePlate.style.width = "90px";
  343.     namePlate.style.textAlign = "center";
  344.     namePlate.style.color = "#FFFFFF";
  345.     namePlate.style.position = "absolute";
  346.     namePlate.style.transform = "translateX(-50%) translateY(-6px)"
  347.     namePlate.style.overflowWrap = "break-word";
  348.     namePlate.style.left = "29px";
  349.     namePlate.style.top = "calc(50% + 39px)";
  350.     iconHolder.style.display = "block";
  351.     iconHolder.appendChild(namePlate);
  352.     nameheight = parseInt(window.getComputedStyle(namePlate).height.replace("px",""))+1;
  353.  
  354.     reply.style.minHeight = (99+nameheight)+"px";
  355.     reply.style.display = "flex";
  356.  
  357.     let separator = document.getElementsByClassName("lastpos")[0];
  358.     if(separator)
  359.       separator.parentNode.removeChild(separator);
  360.  
  361.     /*if(pm.innerHTML == "*"){
  362.     }*/
  363.  
  364.     let topColor = "65,65,65,1";
  365.     let topMiddleColor = "65,65,65,0.95";
  366.     let bottomMiddleColor = "65,65,65,0.85";
  367.     let bottomColor = "65,65,65,0.5";
  368.     replyBubble.style.background = "linear-gradient(to bottom,rgba("+topColor+"),rgba("+topMiddleColor+") 50%,rgba("+bottomMiddleColor+") 50%,rgba("+bottomColor+"))";
  369.     replyBubble.style.border = "solid #FFFFFF 4px";
  370.     replyBubble.style.borderRadius = "13px";
  371.     replyBubble.style.maxWidth = Math.min(window.innerWidth,600)+"px";
  372.     replyBubble.style.minWidth = (18*3)+"px";
  373.     replyBubble.style.width = "auto";
  374.     replyBubble.style.left = "30px";
  375.     replyBubble.style.position = "relative";
  376.    
  377.     replyText.style.color = "#FFFFFF";
  378.     replyText.style.position = "relative";
  379.     replyText.style.fontSize = "18px";
  380.     replyText.style.margin = "18px";
  381.     replyText.style.marginTop = "14px";
  382.     replyText.style.lineHeight = "20px";
  383.     replyText.style.width = "-moz-max-content";
  384.     replyText.style.maxWidth = "max-content";
  385.  
  386.     replyBubble.style.width = (parseInt(window.getComputedStyle(replyText).width.replace("px",""))+18*2+8)+"px";
  387.  
  388.     replyText.style.width = "";
  389.     replyText.style.maxWidth = (Math.min(window.innerWidth,600)-18*2)+"px";
  390.  
  391.     let arrowGradient = document.createElement("div");
  392.     arrowGradient.style.width = "25px";
  393.     arrowGradient.style.height = "13px";
  394.     arrowGradient.style.background = "#000000";
  395.     arrowGradient.style.top = "calc(50% - 1px)";
  396.     arrowGradient.style.transform = "translateY(-50%)";
  397.     arrowGradient.style.left = "-25px";
  398.     arrowGradient.style.position = "absolute";
  399.  
  400.     let arrow = document.createElement("div");
  401.     arrow.style.width = "25px";
  402.     arrow.style.height = "13px";
  403.     let h = parseInt(window.getComputedStyle(replyBubble).height.replace("px",""))/13*100;
  404.     let arrowBackground = "linear-gradient(10deg,rgba(0,0,0,1),rgba(0,0,0,1) calc(40% - 3px),rgba(255,255,255,1) calc(40% - 3px),rgba(255,255,255,1) calc(40% + 1px),rgba(0,0,0,0) calc(40% + 1px),rgba(0,0,0,0)),"+
  405.         "linear-gradient(170deg,rgba(0,0,0,1),rgba(0,0,0,1) calc(40% - 3px),rgba(255,255,255,1) calc(40% - 3px),rgba(255,255,255,1) calc(40% + 1px),rgba(0,0,0,0) calc(40% + 1px),rgba(0,0,0,0)),"+
  406.         "linear-gradient(to bottom,rgba("+topColor+") -"+h+"%,rgba("+topMiddleColor+") calc(50% + 0.5px),rgba("+bottomMiddleColor+") calc(50% + 0.5px),rgba("+bottomColor+") "+h+"%)";
  407.     arrow.style.background = arrowBackground;
  408.     arrowGradient.appendChild(arrow);
  409.     replyBubble.appendChild(arrowGradient);
  410.  
  411.     messages[i].parentNode.removeChild(messages[i]);
  412.  
  413.     if(window.scrollY>0){
  414.       window.scroll(0,0);
  415.       messageList.scroll(0,0);
  416.     }
  417.   }
  418.  
  419.  
  420.   if(!once){
  421.     let header = document.getElementsByClassName("dynamicpanel qwebirc-qui topicboundpanel topic tab-invisible colourline")[0];
  422.     header.parentNode.removeChild(header);
  423.  
  424.     document.body.prepend(input);
  425.     document.body.style.background = "#EEEEEE";
  426.     input.style.paddingLeft = "24px";
  427.     input = document.getElementsByTagName("input")[0];
  428.     let inputBox = document.createElement("textarea");
  429.     input.parentNode.style.width = "725px";
  430.     input.parentNode.style.margin = "auto";
  431.     input.parentNode.style.background = "#EEEEEE";
  432.     input.style.height = "0px";
  433.     input.style.width = "0px";
  434.     input.style.margin = "0px";
  435.     input.style.border = "0px";
  436.     input.style.padding = "0px";
  437.     inputBox.style.width = "460px";
  438.     inputBox.style.height = "65px";
  439.     inputBox.style.overflowWrap = "break-word";
  440.     inputBox.style.overflowX = "hidden";
  441.     inputBox.style.whiteSpace = "normal";
  442.     inputBox.style.background = "#FFFFFF";
  443.     inputBox.style.position = "relative";
  444.     inputBox.style.top = "0px";
  445.     inputBox.style.left = "88px";
  446.     inputBox.style.border = "2px solid #DDDDDD";
  447.     inputBox.placeholder = "";
  448.     inputBox.oninput = ()=>input.value = inputBox.value;
  449.     inputBox.addEventListener("keydown",function(e){
  450.                                             if(e.code=="Enter"){
  451.                                               inputBox.value = "";
  452.                                               input.focus();
  453.                                               input.dispatchEvent(e);
  454.                                             }
  455.                                           });
  456.     input.onkeydown = function(){
  457.                         inputBox.value = "";
  458.                         messageList.scroll(0,0);
  459.                         window.scroll(0,0);
  460.                         inputBox.focus();
  461.                       };
  462.     input.parentNode.appendChild(inputBox);
  463.  
  464.     document.getElementById("ircui").style.top = "4000px";
  465.  
  466.     let user = document.createElement("div");
  467.     user.style.width = "58px";
  468.     user.style.display = "inline-block";
  469.     user.style.position = "absolute";
  470.     user.style.top = "0px";
  471.     let userID = parseInt(ownName.replace("[","").replace(/\].+/,""));
  472.     user.innerHTML = icons[userID].outerHTML+"<div id='nameUnderIcon'>"+ownName.replace(/\[[0-9]+\]/,"")+"</div>";
  473.     input.parentNode.prepend(user);
  474.     let username = document.getElementById("nameUnderIcon");
  475.     username.style.position = "relative";
  476.     username.style.left = "50%";
  477.     username.style.top = "-4px";
  478.     username.style.transform = "translateX(-50%)";
  479.     username.style.width = "100px";
  480.     username.style.overflow = "visible";
  481.     username.style.overflowWrap = "break-word";
  482.     username.style.height = "auto";
  483.     username.style.lineHeight = "18px";
  484.     username.style.textAlign = "center";
  485.  
  486.     inputBox.style.height = (parseInt(window.getComputedStyle(user).height.replace("px",""))-4)+"px";
  487.  
  488.     //let online = document.getElementsByClassName("nicklist tab-invisible dynamicpanel qwebirc-qui rightboundpanel")[0];
  489.     //Create toggleable online list instead of
  490.     let online = document.getElementsByClassName("nicklist tab-invisible dynamicpanel qwebirc-qui rightboundpanel")[0];
  491.     online.parentNode.removeChild(online);
  492.   }
  493.   messageList.setAttribute("class","drrrMessageList");
  494. }
  495.  
  496. function setIcon(id,icon,message){
  497.   icon.innerHTML = icons[id].outerHTML;
  498.   icon.children[0].style.transform = "translateY(-50%)";
  499.   icon.children[0].style.top = "50%";
  500.   icon.children[0].style.position = "relative";
  501. }
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement