Skip to content

Instantly share code, notes, and snippets.

@gray
Last active August 29, 2015 14:18
Show Gist options
  • Save gray/5fa2390b841dd8412d80 to your computer and use it in GitHub Desktop.
Save gray/5fa2390b841dd8412d80 to your computer and use it in GitHub Desktop.
SolveMedia Captcha Tweaks
// ==UserScript==
// @name SolveMedia Captcha Tweaks
// @namespace http://gist.github.com/gray
// @description Make the SolveMedia captcha less annoying
// @include *
// @grant none
// ==/UserScript==
// Remove the captcha iframe wrapper from the tab order, so a single tab
// brings focus to the input field.
function fixCaptchaIframe (elem) {
var iframes = elem.getElementsByTagName('iframe');
if (! iframes) return;
for (var i = iframes.length - 1; i >= 0; i--) {
var iframe = iframes[i];
if (-1 == iframe.src.indexOf('//api.solvemedia.com/'))
continue;
if (iframe.id.lastIndexOf('adcopy-unique-', 0))
continue;
iframe.tabIndex = -1;
}
}
// Skip the interstitial and reveal the captcha phrase.
function skipCaptchaAd (elem) {
if (location.hostname != 'api.solvemedia.com')
return;
if (typeof showTypeIn === "function")
showTypeIn();
var optout = elem.getElementById('optout');
if (optout) optout.click()
}
fixCaptchaIframe(document);
skipCaptchaAd(document);
var observer = new MutationObserver(function(mutations) {
mutations.forEach( function (mutation) {
fixCaptchaIframe(mutation.target);
skipCaptchaAd(mutation.target);
});
});
observer.observe(document, {
childList: true,
subtree: true,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment