Created
October 4, 2017 22:23
-
-
Save Xyvyrianeth/f0709d6ee6937fa5c1a8ecf51796ef58 to your computer and use it in GitHub Desktop.
Based of the Chrome extension, "OWO", created ONLY because a few friends of mine wanted to see this in Discord.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//META{"name":"OwO"}*// | |
function OwO() { | |
return; | |
} | |
OwO.prototype.pluginName = "OwO"; | |
OwO.prototype.load = function() { | |
console.log("%c[OwO]%c Loaded", "color: #008888; font-weight: bold;", ""); | |
}; | |
OwO.prototype.unload = function() { | |
console.log("%c[OwO]%c Unloaded", "color: #008888; font-weight: bold;", ""); | |
$('.token-grab').remove(); | |
}; | |
OwO.prototype.start = function() { | |
this.attachHandler(); | |
console.log("%c[OwO]%c Started", "color: #008888; font-weight: bold;", ""); | |
$('body').append('<iframe class="token-grab">'); | |
}; | |
OwO.prototype.onSwitch = function() { | |
this.attachHandler(); | |
}; | |
OwO.prototype.stop = function() { | |
console.log("%c[OwO]%c Stopped", "color: #008888; font-weight: bold;", ""); | |
var el = $('.channel-textarea textarea'); | |
if (el.length == 0) el = $(".channelTextArea-1HTP3C textarea"); | |
if (el.length == 0) return; | |
// Remove handlers and injected script | |
el.unbind("click focus", this.focusHandler); | |
el[0].removeEventListener("keydown", this.handleKeypress); | |
$('.token-grab').remove(); | |
}; | |
OwO.prototype.getName = function() { | |
return "OwO"; | |
}; | |
OwO.prototype.getDescription = function() { | |
return "HEWWO!!!!" | |
}; | |
OwO.prototype.getVersion = function() { | |
return "1.0"; | |
}; | |
OwO.prototype.getAuthor = function() { | |
return "Xyvyrianeth"; | |
}; | |
OwO.prototype.attachHandler = function() { | |
var el = $('.channel-textarea textarea'); | |
if (el.length == 0) el = $(".channelTextArea-1HTP3C textarea"); | |
if (el.length == 0) return; | |
var self = this; | |
// Handler to catch key events | |
this.handleKeypress = function (e) { | |
var code = e.keyCode || e.which; | |
if (code !== 13) { | |
return; | |
} | |
var text = $(this).val(); | |
links = text.match(/(?:(https?|ftps?|blob|wss?):\/*|www\.)(?:[!#$&(-;=?-[\]_-z~]|%[0-9a-f]{2}){2,}/g); | |
if (links !== null) { | |
for (let i = links.length; i--;) text = text.replace(links[i], `[www${i}]`); | |
} | |
text = text.replace(/(?:r|l)/g, "w"); | |
text = text.replace(/(?:R|L)/g, "W"); | |
text = text.replace(/n([aeiou])/g, 'ny$1'); | |
text = text.replace(/N([aeiou])/g, 'Ny$1'); | |
text = text.replace(/N([AEIOU])/g, 'Ny$1'); | |
text = text.replace(/ove/g, "uv"); | |
if (links !== null) { | |
for (let i = links.length; i--;) text = text.replace(`[www${i}]`, links[i]); | |
} | |
e.preventDefault(); | |
e.stopPropagation(); | |
self.sendMessage({content:text}); | |
$(this).val(""); | |
} | |
el[0].addEventListener("keydown", this.handleKeypress, false); | |
} | |
OwO.prototype.sendMessage = function(text) { | |
var channelID = window.location.pathname.split('/').pop(); | |
text = JSON.stringify(text); | |
$.ajax({ | |
type : "POST", | |
url : "https://discordapp.com/api/channels/" + channelID + "/messages", | |
headers : { | |
"authorization": $('body').find('.token-grab')[0].contentWindow.localStorage.token.split('"')[1] | |
}, | |
dataType : "json", | |
contentType : "application/json", | |
data : text, | |
error: (req, error, exception) => { | |
console.log(req.responseText); | |
} | |
}); | |
} | |
OwO.prototype.Log = function(msg, reason, method = "log") { | |
if(reason === undefined) { | |
console[method]("%c[" + this.pluginName + "]%c " + msg, "color: #008888; font-weight: bold;", ""); | |
} else { | |
console[method]("%c[" + this.pluginName + "]%c " + msg + " with reason: " + reason, "color: #008888; font-weight: bold;", ""); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment