Skip to content

Instantly share code, notes, and snippets.

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 undergroundmonorail/309b441542e68d1b6d62178706b008b6 to your computer and use it in GitHub Desktop.
Save undergroundmonorail/309b441542e68d1b6d62178706b008b6 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Look for fifthglyphs
// @namespace http://www.reddit.com/u/undergroundmonorail
// @version 0.1
// @description Point out fifthglyphs in /r/AVoid5 posts
// @author monorail
// @match *://*.reddit.com/r/AVoid5/comments*
// @match *://*.reddit.com/r/AVoid5/submit*
// @grant none
// ==/UserScript==
(function() {
// fifthglyph constants... i do not think you can author this program without... :(
fifthglyph = String(1>0)[3];
FIFTHGLYPH = fifthglyph["toUpp" + fifthglyph + "rCas" + fifthglyph]();
docum_nt = window["docum" + fifthglyph + "nt"];
// is this HTML doc a spot for posting your own posts?
submission = window.location["hr" + fifthglyph + "f"]["toUpp" + fifthglyph + "rCas" + fifthglyph]()["includ" + fifthglyph + "s"]("/R/AVOID5/SUBMIT");
// is it a spot to discuss a post you saw?
discussion = window.location["hr" + fifthglyph + "f"]["toUpp" + fifthglyph + "rCas" + fifthglyph]()["includ" + fifthglyph + "s"]("/R/AVOID5/COMM" + FIFTHGLYPH + "NTS");
// do nothing if both say "no"
if (submission || discussion)
{
function lookForFifthglyphs()
{
var wordsInPost = '';
$("t" + fifthglyph + "xtar" + fifthglyph + "a[nam" + fifthglyph + "=t" + fifthglyph + "xt]")[fifthglyph + "ach"](function(){
wordsInPost += $(this).prop("valu" + fifthglyph);
});
if (submission)
{
// look through post's alias (a mark on a post you found has no alias)
wordsInPost = $("t" + fifthglyph + "xtar" + fifthglyph + "a.titl" + fifthglyph).prop("valu" + fifthglyph) + " " + wordsInPost;
}
var wordsToLookThrough = wordsInPost.split(/\b/);
var wordsWithFifthglyphs = '';
for (var i=0; i < wordsToLookThrough["l" + fifthglyph + "ngth"]; i++)
{
if (wordsToLookThrough[i]["toUpp" + fifthglyph + "rCas" + fifthglyph]()["includ" + fifthglyph + "s"](FIFTHGLYPH))
{
wordsWithFifthglyphs += '\n' + wordsToLookThrough[i]["r" + fifthglyph + "plac" + fifthglyph](fifthglyph, "■")["r" + fifthglyph + "plac" + fifthglyph](FIFTHGLYPH, "■");
}
}
if (wordsWithFifthglyphs)
{
window["al" + fifthglyph + "rt"]("Fifthglyphs found in your post:\n" + wordsWithFifthglyphs);
}
if (!wordsWithFifthglyphs)
{
window["al" + fifthglyph + "rt"]("No fifthglyphs found! Your post is good to go.");
}
}
var script = docum_nt["cr" + fifthglyph + "at" + fifthglyph + FIFTHGLYPH + "l" + fifthglyph + "m" + fifthglyph + "nt"]('script');
script["app" + fifthglyph + "ndChild"](docum_nt["cr" + fifthglyph + "at" + fifthglyph + "T" + fifthglyph + "xtNod" + fifthglyph](lookForFifthglyphs));
(docum_nt.body || docum_nt["h" + fifthglyph + "ad"] || docum_nt["docum" + fifthglyph + "nt" + FIFTHGLYPH + "l" + fifthglyph + "m" + fifthglyph + "nt"])["app" + fifthglyph + "ndChild"](script);
var id = "button." + (submission ? 'btn' : 'sav' + fifthglyph);
$(id)["b" + fifthglyph + "for" + fifthglyph]('<input typ' + fifthglyph + '="button" valu' + fifthglyph + '="Look For Fifthglyphs" onClick="lookForFifthglyphs();"> ');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment