Created
October 29, 2017 13:03
-
-
Save TechnoTone/dbdf1a58266f59e26ab9324809e16e77 to your computer and use it in GitHub Desktop.
TamperMonkey script for SpamGourmet.com
This file contains hidden or 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 SpamGourmet Hack | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Custom JavaScript to make it easy to manage email addresses on SpamGourmet. | |
// @author Tony Hunt | |
// @match https://www.spamgourmet.com/* | |
// @grant none | |
// @require http://code.jquery.com/jquery-2.2.4.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// @grant GM_addStyle | |
// @grant window.close | |
function autoFix() { | |
console.info("AUTOFIX:"); | |
var tbl = document.getElementsByTagName("table")[0]; | |
tbl = tbl.getElementsByTagName("table")[6]; | |
tbl = tbl.getElementsByTagName("table")[2]; | |
for (var row of tbl.rows) { | |
var cells = row.getElementsByTagName("td"); | |
var name = cells[0].textContent; | |
var count = cells[2].textContent; | |
if (count < 15) { | |
var link = cells[0].childNodes[0].href; | |
var w = window.open(link, '_blank'); | |
} | |
} | |
} | |
function last(array, n) { | |
if (array == null) | |
return void 0; | |
if (n == null) | |
return array[array.length - 1]; | |
return array.slice(Math.max(array.length - n, 0)); | |
} | |
function containsHtml(obj, match) { | |
return obj.innerHTML.toLowerCase().indexOf(match) >= 0; | |
} | |
function containsButton(obj, buttonText) { | |
return containsHtml(obj, 'input type="submit" value="add a watchword"'); | |
} | |
if (containsButton(document.body, 'add a watchword')) { | |
console.info("Found: Main Page"); | |
var frm = document.getElementsByTagName("form")[5]; | |
if (frm.innerHTML.indexOf('input type="submit" value="search addresses">') >= 0) { | |
var flds = frm.getElementsByTagName("input"); | |
flds[1].value = ""; | |
flds[3].value = "OPENING..."; | |
frm.submit(); | |
} else { | |
console.error("HMM: Couldn't find Search Addresses form! :/"); | |
} | |
} else if (document.body.innerHTML.indexOf('<input type="submit" value="search addresses">') >= 0) { | |
console.info("Found: Addresses Page"); | |
// This is the code to sort the table by the "remaining" column. | |
var tbl = last(document.getElementsByTagName("table")); | |
var remaining = tbl.getElementsByTagName("thead")[0].getElementsByTagName("td")[2]; | |
var e = {}; | |
e.target = remaining; | |
sortColumn(e); | |
var inputElements = $("input"); | |
$.each(inputElements, function(index, element) { | |
if (element.value == "search addresses") { | |
console.info("Found: Search Button"); | |
var fix = $('<input id="MyAutoFixButton" type="button" value="AutoFix" />'); | |
$(fix).insertAfter($(element)); | |
$("#MyAutoFixButton").click (autoFix); | |
//$(element).after(fix); | |
} | |
}); | |
} else if (document.body.innerHTML.indexOf('<input type="submit" value="update address">') >= 0) { | |
console.info("Found: Update Page"); | |
var frm = document.getElementsByTagName("form")[4]; | |
var flds = frm.getElementsByTagName("input"); | |
for (var fld of flds) { | |
if (fld.name == "count") { | |
if (fld.value == "20") { | |
window.close(); | |
} else { | |
fld.value = "20"; | |
frm.submit(); | |
} | |
} | |
} | |
} else if (window.location.href.endsWith("/index.pl")) { | |
console.info("Found: Post-Edit Page"); | |
var tbl = document.getElementsByTagName("table")[10]; | |
if (tbl.rows.length == 2) { | |
console.info("close!!!!"); | |
window.close(); | |
} | |
} | |
console.info("finished"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment