Skip to content

Instantly share code, notes, and snippets.

@Xyvyrianeth
Last active October 5, 2017 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xyvyrianeth/f79f5d2a34fbda7742f17bff7f96b00b to your computer and use it in GitHub Desktop.
Save Xyvyrianeth/f79f5d2a34fbda7742f17bff7f96b00b 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.
//META{"name":"OwO","author":"Xyvyrianeth","version":"1.2"}*//
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.2";
};
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 || e.shiftKey) {
return;
}
var text = $(this).val();
e.preventDefault();
e.stopPropagation();
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(/m([aeiou])/g, 'my$1');
text = text.replace(/M([aeiou])/g, 'My$1');
text = text.replace(/M([AEIOU])/g, 'MY$1');
text = text.replace(/ove/g, "uv");
if (links !== null) {
for (let i = links.length; i--;) text = text.replace(`[www${i}]`, links[i]);
}
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();
$.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 : JSON.stringify(text),
error: (req, error, exception) => {
console.log(req.responseText);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment