Skip to content

Instantly share code, notes, and snippets.

@ngraf
Last active May 25, 2021 12:32
Show Gist options
  • Save ngraf/ecd7e053b3f8061a3dd089e38cefdc97 to your computer and use it in GitHub Desktop.
Save ngraf/ecd7e053b3f8061a3dd089e38cefdc97 to your computer and use it in GitHub Desktop.
Selenium Blackhole Proxy
/**
* @return {string}
*/
function FindProxyForURL(url, host)
{
'use strict';
var url2 = url.substring(url.indexOf("//")+2); // removing http*://
var urlMatch;
if(url2.indexOf("/") != -1) {
urlMatch = url2.split("/");
} else if(url2.indexOf(".") != -1) {
urlMatch = url2.split(".");
} else {
urlMatch = url2.split("?");
}
var urlMatch1 = urlMatch[0];
var use_proxy_blackhole = "PROXY 127.0.0.1:3421";
/****************************************************************************************************
*
* Proxy Blackhole
*
***************************************************************************************************/
if ( shExpMatch(urlMatch1, 'cm.adform.net*')
|| shExpMatch(urlMatch1, 'bam.nr-data.net*')
|| shExpMatch(urlMatch1, 'adnxs.com*')
|| shExpMatch(urlMatch1, 'connect.facebook.net')
|| shExpMatch(urlMatch1, 'betrad.com*')
|| shExpMatch(urlMatch1, 'bidswitch.net*')
|| shExpMatch(urlMatch1, 'criteo.com*')
|| shExpMatch(urlMatch1, 'doubleclick.net*')
|| shExpMatch(urlMatch1, 'eprofile.uimserv.net*')
|| shExpMatch(urlMatch1, 'facebook.com*')
|| shExpMatch(urlMatch1, 'flex.atdmt.com*')
|| shExpMatch(urlMatch1, 'google.com*')
|| shExpMatch(urlMatch1, 'google.de*')
|| shExpMatch(urlMatch1, 'google-analytics.com*')
|| shExpMatch(urlMatch1, 'marketingsolutions.yahoo.com*')
|| shExpMatch(urlMatch1, 'pagead2.googlesyndication.com*')
|| shExpMatch(urlMatch1, 'pixel.rubiconproject.com*')
|| shExpMatch(urlMatch1, 'qs.ioam.de*')
|| shExpMatch(urlMatch1, 'r.msn.com*')
|| shExpMatch(urlMatch1, 'sociomantic.com*')
|| shExpMatch(urlMatch1, 'smartadserver.com*')
|| shExpMatch(urlMatch1, 'ssl.gstatic.com*')
|| shExpMatch(urlMatch1, 'ssl.xplosion.de*')
|| shExpMatch(urlMatch1, 'yimg.com*')
|| shExpMatch(urlMatch1, 'd.yimg.com*')
|| shExpMatch(urlMatch1, 'zanox.com*')
|| shExpMatch(urlMatch1, 'pubmatic.com*')
|| shExpMatch(urlMatch1, 'mc.yandex.ru*')
|| shExpMatch(urlMatch1, 'rainbow-de.mythings.com*')
|| shExpMatch(urlMatch1, 'sonar.sociomantic.com*')
|| shExpMatch(urlMatch1, 'yieldpartners.com*')
|| shExpMatch(urlMatch1, 'analytics.twitter.com*')
|| shExpMatch(urlMatch1, 'flex.msn.com*')
|| shExpMatch(urlMatch1, 'delivery.swid.switchads.com*')
|| shExpMatch(urlMatch1, 'asn.advolution.de*')
|| shExpMatch(urlMatch1, 'bat.r.msn.com*')
|| shExpMatch(urlMatch1, 'bat.bing.com*')
|| shExpMatch(urlMatch1, 'de.ioam.de*')
|| shExpMatch(urlMatch1, 'ads.stickyadstv.com*')
|| shExpMatch(urlMatch1, 'ssp.adriver.ru*')
|| shExpMatch(urlMatch1, 'the-internet.herokuapp.com*') // for url == 'http://the-internet.herokuapp.com/slow_external'
// more user specific
|| shExpMatch(urlMatch1, 'cdn.optimizely.com*') // Optimizely (A/B tests)
|| shExpMatch(urlMatch1, 'logx.optimizely.com*') // Optimizely (A/B tests)
|| shExpMatch(urlMatch1, 'o2.mouseflow.com*') // Mouseflow: User monitoring
|| shExpMatch(urlMatch1, 'trc.taboola.com*') // Taboola tracking
) {
return use_proxy_blackhole;
}
return "DIRECT";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment