Skip to content

Instantly share code, notes, and snippets.

@arlolra arlolra/bootstrap.js
Created Apr 21, 2014

Embed
What would you like to do?
ROT13 Transform
const { utils: Cu } = Components;
Cu.import("resource:///modules/imServices.jsm");
function rot13(aString)
aString.replace(/[a-zA-Z]/g, function(c)
String.fromCharCode(c.charCodeAt(0) + (c.toLowerCase() < "n" ? 1 : -1) * 13));
function rotOn(tMsg, aConv, aCb) {
tMsg.toSend = rot13(tMsg.toSend);
aCb.invoke();
}
let rotTransform = {
onSend: rotOn,
onReceive: rotOn
};
let originalAddConversation;
function startup() {
let cs = Services.conversations.wrappedJSObject;
originalAddConversation = cs.addConversation;
cs.addConversation = function(prplIConvIM) {
prplIConvIM.addTransform(rotTransform);
originalAddConversation.call(cs, prplIConvIM);
};
}
function shutdown() {
if (reason === APP_SHUTDOWN)
return;
let cs = Services.conversations.wrappedJSObject;
for each (let prplIConvIM in cs.getUIConversations())
prplIConvIM.removeTransform(rotTransform);
cs.addConversation = originalAddConversation;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.