Skip to content

Instantly share code, notes, and snippets.

@LLCampos
Created May 14, 2019 19:58
Show Gist options
  • Save LLCampos/28642230d0c7656343eebfa258d3d8e6 to your computer and use it in GitHub Desktop.
Save LLCampos/28642230d0c7656343eebfa258d3d8e6 to your computer and use it in GitHub Desktop.
Tapermonkey user script. An experiment on improving chat conversations. Changes the color of Messenger or WhatsApp text box every time I start to write about myself.
// ==UserScript==
// @name Am I talking about me again?
// @namespace
// @version 0.1
// @description Find references to myself in messaging web apps
// @author
// @match
// @grant none
// ==/UserScript==
(function() {
'use strict';
var inputQuery
var host = window.location.hostname
if (host.includes("messenger")) {
inputQuery = "._1mf"
} else if (host.includes("whatsapp")) {
inputQuery = "._2S1VP"
}
var expressionString = /\beu\b|\bmim\b|\bacho\b|-me\b|\bestou\b/
function isItAboutMe(text) {
return new RegExp(expressionString, 'i').test(text)
}
document.onkeypress = function() {
var inputText = document.querySelector(inputQuery);
if (isItAboutMe(inputText.innerText)) {
inputText.style.backgroundColor = "#C9ADF3"
} else {
inputText.style.backgroundColor = "white"
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment