Last active
August 29, 2015 14:18
-
-
Save gray/5fa2390b841dd8412d80 to your computer and use it in GitHub Desktop.
SolveMedia Captcha Tweaks
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 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