-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchatcommands.user.js
More file actions
64 lines (61 loc) · 2.31 KB
/
chatcommands.user.js
File metadata and controls
64 lines (61 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// ==UserScript==
// @name Chat Commands
// @namespace http://tampermonkey.net/
// @version 0.4.0
// @description Add some simple ascii art commands.
// @author Teh Flamin' Taco
// @include *://chat.meta.stackoverflow.com/rooms/*
// @include *://chat.meta.stackexchange.com/rooms/*
// @include *://chat.stackexchange.com/rooms/*
// @include *://chat.stackoverflow.com/rooms/*
// @include *://chat.askubuntu.com/rooms/*
// @include *://chat.serverfault.com/rooms/*
// @updateURL https://rawgit.com/TehFlaminTaco/TacosUserscripts/blob/master/chatcommands.user.js
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
var codes = {
shrug: "¯\\\\_(ツ)_/¯",
tableflip: "(ノ°Д°)ノ︵ ┻━┻",
"o(_+)o": "ಠ$1ಠ",
disapprove: "ಠ_ಠ",
like: "(•◡•)/",
unflip: "┬─┬ ノ( ゜-゜ノ)",
donger: "༼ つ ◕_◕ ༽つ",
why: "ლ(ಠ益ಠლ)",
cool: "(▀̿Ĺ̯▀̿ ̿)",
lenny: "( ͡° ͜ʖ ͡°)",
borkalert: "BORK ALERT 🚨 BORK ALERT 🚨 BORK ALERT",
["\\$(\\$?)(.+?)\\$\\1"]: function(_, a, s) {
return "https://a-ta.co/mathjax/"+ encodeURIComponent(a) + "!" + btoa(s) + ".svg";
},
[":(.*?):"]: (_, a)=>{
if(window.emoji){
for(var category in window.emoji){
for(var i=0; i < window.emoji[category].length; i++){
if(window.emoji[category][i].description == a || window.emoji[category][i].aliases.find((x)=>x==a)){
return window.emoji[category][i].emoji;
}
}
}
return _;
}else{
return _;
}
},
["\\|([^\"]+?)\\|"]: function(_, a, s){
return `[spoiler](https://www.github.com/TehFlaminTaco/TacosUserscripts "${a}")`
}
};
setInterval(function() {
for (let code in codes) {
let x = document.getElementById("input");
x.value = x.value.replace(new RegExp("(?:\\s|^)/" + code), function(m){
var s = m.match(/^(\s*)\/(.*)/)
return s[1]+s[2].replace(new RegExp(code),codes[code])
});
}
}, 300);
})();