? Chat JS Add-Ons (Page 2) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
This is the development website, where we test out new features. This isn't the place you're looking for! Go here

Chat JS Add-Ons

1 2 3 4
  • #21 ✎ 97 12Me21 Forum Moderator Bees Hidden Easter Eggs Reading I like to read books! Hobbies Avatar Taboo I didn't change my avatar for 180 days Website /manual is broken? Posted
  • #22 ✎ 242 Lumage Head Admin Gardening I like to garden! Hobbies Reading I like to read books! Hobbies Drawing I like to draw! Hobbies was fix Posted
  • #23 ✎ 242 Lumage Head Admin Gardening I like to garden! Hobbies Reading I like to read books! Hobbies Drawing I like to draw! Hobbies WIP RPG utilities /* ***************** *\ |* Die/Name Commands *| \* ***************** */ var rpUsername = document.querySelector('body').getAttribute('data-username'); var playerNames = {}; playerNames[rpUsername] = rpUsername; function roll(n) { //Rolls an n-sided die return Math.floor(Math.random() * n) + 1; } commands.push(new Command("rpSetName", function(param) { var name = param.substring(1); if (name.length > 40) { warningMessage("That's not a valid name."); return; } playerNames[rpUsername] = name; sendMessage("[rpl21nick] " + rpUsername + "'s name is now " + name); })); commands.push(new Command("roll", function(param) { var params = quickParamParse(param); if (params.length > 2) { warningMessage("what the hell you tryna pull"); return; } var n; if (params.length === 0) { n = 20; } else { n = params[0]; } var grammar = ""; result = roll(n); if (result === 8 || result === 18 || result === 11) { grammar = "n"; } sendMessage("[rpl21roll] " + playerNames[rpUsername] + " rolled a d" + n + " and got " + result + "!"); })); addMessageEvent(function(messageElement) { if (messageElement.querySelector("message-part") && messageElement.querySelector("message-part").innerText.indexOf("[rpl21") === 0) { var content = messageElement.querySelector("message-part").innerText; var command = content.substring("[rpl21".length, content.indexOf("]")); switch (command) { case "nick": playerNames[messageElement.dataset.user.toString()] = content.substring(content.indexOf("name is now ") + "name is now ".length); break; } } if (messageElement.dataset.user && !messageElement.className && playerNames && playerNames[messageElement.dataset.user.toString()]) { messageElement.querySelector("figcaption").innerHTML = playerNames[messageElement.dataset.user].replace(/[<>.'"(){}\\]/g, ""); } return false; }); Posted Edited by Lumage
  • #24 ✎ 242 Lumage Head Admin Gardening I like to garden! Hobbies Reading I like to read books! Hobbies Drawing I like to draw! Hobbies import saved drawings (admin only) commands.push(new Command("drawimport", function(param) { var params = quickParamParse(param); var xoff = 0; var yoff = 0; if(params.length > 3) { warningMessage("You're not even fucking clever."); return; } else if (params.length === 3) { xoff = params[1]; yoff = params[2]; } if (params[0].substring(0,4) !== "http") { params[0] = "http://smilebasicsource.com/scratch/"; + params[0]; } var image = new Image(); image.src=params[0]; console.log(image); bitmap = createImageBitmap(image); console.log(bitmap); canvas = document.querySelector("#chatdraw canvas"); bitmap.then(function(result) { canvas.getContext("2d").drawImage(result,xoff,yoff); }); })); Posted
  • #25 ✎ 97 12Me21 Forum Moderator Bees Hidden Easter Eggs Reading I like to read books! Hobbies Avatar Taboo I didn't change my avatar for 180 days Website http://pastebin.com/3QkV3WtB (Probably outdated) Posted Edited by 12Me21
  • #26 ✎ 31 Chemicale commands.push(new Command("omiwa", function(param){var params = quickParamParse(param);if(params.length > 1){var string="";for(var i = 0, len = params.length; i < len; i++) {if(i<params.length-1){string=string+params[i]+" ";}else{string=string+params[i];}}sendMessage(string+", maybe.");}})); Posted Edited by Chemicale
  • #27 ✎ 106 Sparky Power User Deep Sleep Hidden Website
    commands.push(new Command("omiwa", function(param){var params = quickParamParse(param);if(params.length > 1){var string="";for(var i = 0, len = params.length; i < len; i++) {if(i<params.length-1){string=string+params[i]+" ";}else{string=string+params[i];}}sendMessage(string+", maybe.");}}));
    Woah, that may be the best command for, like, anything, maybe.
    Posted
  • #28 ✎ 97 12Me21 Forum Moderator Bees Hidden Easter Eggs Reading I like to read books! Hobbies Avatar Taboo I didn't change my avatar for 180 days Website var sendpane=document.getElementById("sendpane"); var textarea=sendpane.getElementsByTagName("textarea")[0]; var newline=document.createElement("button"); newline.innerHTML="\\n"; newline.style.width="3rem"; newline.onclick=function(e){ textarea.value+="\n"; textarea.focus(); e.preventDefault(); } sendpane.insertBefore(newline,sendpane.getElementsByTagName("input")[0]); Posted
  • #29 ✎ 28 Perska Cthulhu Join the cult Easter Eggs Bees Hidden Easter Eggs document.body.style.overflow="hidden"; var sidebarButt=document.createElement("input"); sidebarButt.type="button"; sidebarButt.value="YES"; sidebarButt.onclick=function() { var chatpane=document.querySelector("#chatpane"); var sidebar=document.querySelector("#sidepane"); if (this.value=="YES") { sidebar.style.width="0%"; sidebar.style.height="0%" chatpane.style.width="100%"; this.value="NO"; } else { sidebar.style.width="25%"; sidebar.style.height="100%" chatpane.style.width="75%"; this.value="YES"; } }; document.querySelector("#sendpane").appendChild(sidebarButt); Posted
  • #30 ✎ 2 BillyTheWRECK
    document.body.style.overflow="hidden"; var sidebarButt=document.createElement("input"); sidebarButt.type="button"; sidebarButt.value="YES"; sidebarButt.onclick=function() { var chatpane=document.querySelector("#chatpane"); var sidebar=document.querySelector("#sidepane"); if (this.value=="YES") { sidebar.style.width="0%"; sidebar.style.height="0%" chatpane.style.width="100%"; this.value="NO"; } else { sidebar.style.width="25%"; sidebar.style.height="100%" chatpane.style.width="75%"; this.value="YES"; } }; document.querySelector("#sendpane").appendChild(sidebarButt);
    document.body.style.overflow="hidden"; var sidebarButt=document.createElement("input"); sidebarButt.type="button"; sidebarButt.value="YES"; sidebarButt.onclick=function() { var chatpane=document.querySelector("#chatpane"); var sidebar=document.querySelector("#sidepane"); if (this.value=="YES") { sidebar.style.display="none"; chatpane.style.width="100%"; this.value="NO"; } else { sidebar.style.display="block"; chatpane.style.width="75%"; this.value="YES"; } }; document.querySelector("#sendpane").appendChild(sidebarButt);
    Posted
  • #31 ✎ 28 Perska Cthulhu Join the cult Easter Eggs Bees Hidden Easter Eggs
    document.body.style.overflow="hidden"; var sidebarButt=document.createElement("input"); sidebarButt.type="button"; sidebarButt.value="YES"; sidebarButt.onclick=function() { var chatpane=document.querySelector("#chatpane"); var sidebar=document.querySelector("#sidepane"); if (this.value=="YES") { sidebar.style.width="0%"; sidebar.style.height="0%" chatpane.style.width="100%"; this.value="NO"; } else { sidebar.style.width="25%"; sidebar.style.height="100%" chatpane.style.width="75%"; this.value="YES"; } }; document.querySelector("#sendpane").appendChild(sidebarButt);
    document.body.style.overflow="hidden"; var sidebarButt=document.createElement("input"); sidebarButt.type="button"; sidebarButt.value="YES"; sidebarButt.onclick=function() { var chatpane=document.querySelector("#chatpane"); var sidebar=document.querySelector("#sidepane"); if (this.value=="YES") { sidebar.style.display="none"; chatpane.style.width="100%"; this.value="NO"; } else { sidebar.style.display="block"; chatpane.style.width="75%"; this.value="YES"; } }; document.querySelector("#sendpane").appendChild(sidebarButt);
    using display: none causes the elements to unload, which is bad
    Posted
  • #32 ✎ 149 randomouscrap98 Owner Touhou Project Is Awesome! I love Touhou Project! Express Yourself Second Year My account is over 2 years old Website Gardening I like to garden! Hobbies Best proxy bests beasts, bets beets beat Bess (use this code in chatJS to allow the chat to run through the proxy rather than websockets when ?proxy=1 is added to the url. In other words, adding ?proxy=1 to chat will disable websockets for those of you who can't use them.) sendProxyMessage.proxyID = Math.random() + "_" + Date.now(); sendProxyMessage.statusDumper = document.getElementById("sendpane"); retrieveProxyMessages.interval = 1000; function sendProxyMessage(type, data, callback) { var formData = new FormData(); var proxyMessage = {"proxyID" : sendProxyMessage.proxyID, "type" : type, "data" : Base64.encode(data), "encoding" : "base64"}; formData.append("data", JSON.stringify(proxyMessage)); genericXHR("/query/submit/chatproxy", formData, sendProxyMessage.statusDumper, callback); } function retrieveProxyMessages() { if(sendProxyMessage.statusDumper.dataset.status === "ERROR") { systemMessage('You were disconnected. <a href="">Reconnect?</a>'); return; } sendProxyMessage("proxyReceive", null, function(json, element) { for(var i = 0; i < json.result.length; i++) { onMessage({"data":json.result[i]}); } setTimeout(retrieveProxyMessages, retrieveProxyMessages.interval); }); } if(getQueryVariable("proxy")) { if(Socket && Socket.close) Socket.close(); Socket = { "close" : sendProxyMessage.callBind("proxyEnd", null), "send" : function(message) { sendProxyMessage("proxySend", message); } }; sendProxyMessage("proxyStart", null, function() { var connect = {'type': 'bind','uid': Number(useruid),'key': auth}; sendProxyMessage("proxySend", JSON.stringify(connect)) }); setTimeout(retrieveProxyMessages, retrieveProxyMessages.interval); } Note: this is a smilebasicsource proxy. I'm not redirecting you outside the website in order to evade websockets: this is a system I created and it's all within the website. It is normal to see "You were disconnected" when starting the page in proxy mode: this is because I have to shut off the websockets before I start up the proxy. Posted Edited by randomouscrap98
  • #33 ✎ 31 Chemicale
    Best proxy bests beasts, bets beets beat Bess
    Bees
    Posted
  • #34 ✎ 149 randomouscrap98 Owner Touhou Project Is Awesome! I love Touhou Project! Express Yourself Second Year My account is over 2 years old Website Gardening I like to garden! Hobbies Swap user avatars with ones that you want (made for Omiwa) addMessageEvent(function(messageElement) { //Add whatever user to avatar image mapping you want here. This example //changes Random's avatar to be one from his deviantart. var mapping = {2 : "http://a.deviantart.net/avatars/r/a/randomouscrap.png"}; try { var uid = messageElement.dataset.user; if(mapping[uid]) messageElement.querySelector("figure img").src = mapping[uid]; } catch(e){ /* Do what you want with errors here */ } }); Posted
  • #35 ✎ 97 12Me21 Forum Moderator Bees Hidden Easter Eggs Reading I like to read books! Hobbies Avatar Taboo I didn't change my avatar for 180 days Website /*-----*\ | Title | \*-----*/ (function(){ var currentFavicon="" function changeFavicon(src) { if (src==currentFavicon) return currentFavicon=src var link=document.createElement("link") var oldLink=document.getElementById("dynamic-favicon") link.id="dynamic-favicon" link.rel="shortcut icon" link.href=src if (oldLink) document.head.removeChild(oldLink) document.head.appendChild(link) } changeFavicon("") var titleTag=document.getElementsByTagName("title")[0] addMessageEvent(function(messageElement) { if (messageElement.className) { changeFavicon("") titleTag.innerHTML=messageElement.textContent } else if(ignoreList.indexOf(Number(messageElement.dataset.user))==-1) { changeFavicon(messageElement.querySelector("figure img").src) titleTag.innerHTML=messageElement.querySelector("message-content:last-of-type").textContent } }) })() Posted Edited by 12Me21
  • #36 ✎ 242 Lumage Head Admin Gardening I like to garden! Hobbies Reading I like to read books! Hobbies Drawing I like to draw! Hobbies window.setInterval(function(){sendMessage("/coinget");}, 361000); Posted Edited by Lumage
  • #37 ✎ 26 Guzzler829 Here's a handy thing to clear module messages: //modcls commands.push(new Command("modcls", function(){ while(document.querySelector(".modulemessage")){removeSelf(document.querySelector(".modulemessage"))} systemMessage("Module messages removed"); })); Here's one for system messages: //syscls commands.push(new Command("syscls", function(){ while(document.querySelector(".sysmessage")){removeSelf(document.querySelector(".sysmessage"))} systemMessage("System messages removed"); })); Here's one for warning messages: //warcls commands.push(new Command("warcls", function(){ while(document.querySelector(".warningmessage")){removeSelf(document.querySelector(".warningmessage"))} systemMessage("Warning messages removed"); })); And here's one that clears everything except normal messages in one command: //allcls commands.push(new Command("allcls", function(){ while(document.querySelector(".modulemessage")){removeSelf(document.querySelector(".modulemessage"))} while(document.querySelector(".sysmessage")){removeSelf(document.querySelector(".sysmessage"))} while(document.querySelector(".warningmessage")){removeSelf(document.querySelector(".warningmessage"))} systemMessage("System, module, and warning messages removed"); })); Posted Edited by Guzzler829
  • #38 ✎ 38 snail_ Avatar Taboo I didn't change my avatar for 180 days Website Deep Sleep Hidden Website Minecraft Is Awesome! I love Minecraft! Express Yourself Chat Notifier Uses Notification API to send you a notif whenever a user sends a message. You will not receive a notif if:
    1. It is from a user you ignore
    2. The chat window is focused and visible
    3. It is from a message you sent
    Notifications are bound to auto-clear after 60 seconds (assuming your device doesn't do it sooner.) They may/may not vibrate your device, play a ringtone, wake up your phone etc. I'm just doing what the Notification API is telling me. If something doesn't work hmu. //message notifier { var focused = true; window.addEventListener("focus", function() { focused = true; }); window.addEventListener("blur", function() { focused = false; }); document.addEventListener("visibilitychange", function() { focused = document.visibilityState == "visible"; }); var notify = function(elem) { if(focused) return; if(ignoreList.includes(parseInt(elem.dataset.user))) return; if(document.body.dataset.uid == elem.dataset.user) return; var opts = { icon: elem.querySelector("figure img").src, body: elem.querySelector("message-content message-part:last-of-type").textContent, vibrate: [500], badge: elem.querySelector("figure img").src, tag: elem.dataset.tags }; var n = new Notification("New message from " + elem.dataset.username, opts); window.setTimeout(n.close.bind(n), 60000); }; var init = function() { if("Notification" in window) { Notification.requestPermission(function(permission) { if(permission === "granted") addMessageEvent(notify); }); } }; window.setTimeout(init, 5000); } EDIT: this sucks and I'm gonna replace it or something.
    Posted Edited by snail_
  • #39 ✎ 149 randomouscrap98 Owner Touhou Project Is Awesome! I love Touhou Project! Express Yourself Second Year My account is over 2 years old Website Gardening I like to garden! Hobbies Donger 1.0 (not all that great yet) var allDongers = { "happy" : ["ᕕ( ՞ ᗜ ՞ )ᕗ", "ᕕ( ⁰ ▽ ⁰ )ᕗ", "┗(^0^)┓", "( ^◡^)"], "angry" : ["ლ(ಠ益ಠლ)", "୧( ಠ Д ಠ )୨", "(つ◉益◉)つ"], "pout" : ["(ヾノ•᷅ ༬•᷄ )"], "thumbsup" : ["s( ^ ‿ ^)-b"], "thumbsdown" : ["s( ^ ‸ ^)-p"], "wow" : ["(⊙ᗜ⊙)"], "monacle" : ["(╭ರ_•́)"], "shocked" : ["(ʘᗩʘ’)"], "why" : ["ლ(ಥ Д ಥ )ლ"], "want" : ["c(ˊᗜˋ*c)"], "ohwell" : ["乁( ◔ ౪◔)ㄏ"], "sad" : ["(-_-。)", "(ಥ﹏ಥ)"], "dog" : ["(V●ᴥ●V)"], "table" : ["(╯°□°)╯︵ ┻━┻", "_|___|_ ╰(º o º╰)", "(ノಠдಠ)ノ︵┻━┻", "┻━┻ ヘ╰( •̀ε•́ ╰)"], "lenny" : ["( ͡° ͜ʖ ͡°)"] }; commands.push(new Command("donger", function(param) { //The "param" is just a big string of all the parameters. //Use this function to split it based on spaces. var params = quickParamParse(param); if(params.length < 1) { warningMessage("You're using it wrong! Example: /donger happy [specificDonger]"); return; } if(params[0].toLowerCase().trim() === "help") { var output = "Available dongers:\n"; for(var key in allDongers) { if(allDongers.hasOwnProperty(key)) { output += "-" + key + "\t\t(" + allDongers[key].length + " donger(s))\n"; } } localModuleMessage(output); } else { try { var key = params[0]; if(!allDongers[key]) { warningMessage("There are no dongers for \"" + key + "\""); return; } var donger = intRandom(allDongers[key].length); if(params.length > 1) donger = params[1]; if(!allDongers[key][donger]) { warningMessage("The donger ID for " + key + " was out of range (" + donger + ")"); return; } sendMessage(allDongers[key][donger]); } catch(ex) { warningMessage("Something went wrong with the donger command"); } } }, "Output a donger (unicode text emoticon) from various categories")); Posted
  • #40 ✎ 73 ElzoBro
    WIP RPG utilities var rpUsername = document.querySelector('body').getAttribute('data-username'); function roll(n) { //Rolls an n-sided die return Math.floor(Math.random() * n) + 1; } commands.push(new Command("rpSetName", function(param) { var name = param.substring(1); if (name.length > 40) { warningMessage("That's not a valid name."); return; } sendMessage("[rpl20nick] " + rpUsername + "'s name is now " + name); })); commands.push(new Command("roll", function(param) { var params = quickParamParse(param); if (params.length > 2) { warningMessage("what the hell you tryna pull"); return; } var n; if (params.length === 0) { n = 20; } else { n = params[0]; } var grammar = ""; result = roll(n); if (result === 8 || result === 18 || result === 11) { grammar = "n"; } sendMessage("[rpl20roll] " + rpUsername + " rolled a" + grammar + " " + result + "!"); })); var playerNames = new Object(); addMessageEvent(function(messageElement) { if (messageElement.querySelector("p") && messageElement.querySelector("p").innerHTML.indexOf("[rpl20") === 0) { var content = messageElement.querySelector("p").innerHTML; var command = content.substring("[rpl20".length, content.indexOf("]")); switch (command) { case "nick": playerNames[messageElement.dataset.user.toString()] = content.substring(content.indexOf("name is now ") + "name is now ".length); break; } } if (messageElement.dataset.user && !messageElement.className && playerNames && playerNames[messageElement.dataset.user.toString()]) { messageElement.querySelector("figcaption").innerHTML = playerNames[messageElement.dataset.user].replace(/[<>.'"(){}\\]/g, ""); } return false; });
    Lumage when are you gonna update the RPG utilities? /rpsetname doesnt even work anymore lol
    Posted
1 2 3 4