Created
January 15, 2013 00:05
-
-
Save yorickvP/4534733 to your computer and use it in GitHub Desktop.
warn when you're about to tweet "thanks to me"
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
// ==UserScript== | |
// @name Warn when you're about to tweet "thanks to me" | |
// @namespace http://localhost/ | |
// @version 0.1 | |
// @description Add an alert whenever someone types "thanks to me" | |
// @match http://twitter.com/* | |
// @match https://twitter.com/* | |
// ==/UserScript== | |
(function() { | |
var containing = false | |
window.addEventListener("keyup", function(event) { | |
function istweetbox_p(elem) { | |
return elem.className.split(' ').indexOf('tweet-box') != -1 } | |
function contains_selfishness_p(elem) { | |
return !!elem.value.match(/thanks *to *me/i) } | |
if (istweetbox_p(event.target)) { | |
var tweetbox = event.target | |
if (contains_selfishness_p(tweetbox)) { | |
if (!containing) { | |
window.alert("You are about to tweet something containing"+ | |
" \"thanks to me\", this was probably(hopefully) an error") | |
containing = true }} | |
else if (containing) | |
containing = false }}, false); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment