// ==UserScript==
// @name AdsBypasser
// @namespace AdsBypasser
// @description Bypass Ads
// @copyright 2012+, Wei-Cheng Pan (legnaleurc)
// @version 5.35.0
// @license BSD
// @homepageURL https://adsbypasser.github.io/
// @supportURL https://github.com/adsbypasser/adsbypasser/issues
// @icon https://raw.githubusercontent.com/adsbypasser/adsbypasser/v5.35.0/img/logo.png
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @grant GM_getValue
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @run-at document-start
// @resource alignCenter https://raw.githubusercontent.com/adsbypasser/adsbypasser/v5.35.0/css/align_center.css
// @resource scaleImage https://raw.githubusercontent.com/adsbypasser/adsbypasser/v5.35.0/css/scale_image.css
// @resource bgImage https://raw.githubusercontent.com/adsbypasser/adsbypasser/v5.35.0/img/imagedoc-darknoise.png
// @include http://*
// @include https://*
// @downloadURL none
// ==/UserScript==
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var bluebird = require('bluebird');
module.exports = factory(context, bluebird.Promise);
} else {
var P = null;
if (context.unsafeWindow.Future) {
P = function (fn) {
return context.unsafeWindow.Future.call(this, function (fr) {
fn(fr.resolve.bind(fr), fr.reject.bind(fr));
});
};
} else if (context.PromiseResolver) {
P = function (fn) {
return new context.Promise(function (pr) {
fn(pr.resolve.bind(pr), pr.reject.bind(pr));
});
};
} else {
P = context.Promise;
}
factory(context, P);
}
}(this, function (context, Promise) {
'use strict';
var _ = context._ = {};
function setupStack () {
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
} else if (!this.hasOwnProperty('stack')) {
var stack = (new Error()).stack.split('\n').slice(2);
var e = stack[0].match(/^.*@(.*):(\d*)$/);
this.fileName = e[1];
this.lineNumber = parseInt(e[2], 10);
this.stack = stack.join('\n');
}
}
function AdsBypasserError (message) {
setupStack.call(this);
this.message = message;
}
AdsBypasserError.prototype = Object.create(Error.prototype);
AdsBypasserError.prototype.constructor = AdsBypasserError;
AdsBypasserError.prototype.name = 'AdsBypasserError';
AdsBypasserError.extend = function (protoProps, staticProps) {
var parent = this, child = function () {
setupStack.call(this);
protoProps.constructor.apply(this, arguments);
};
extend(child, parent, staticProps);
child.prototype = Object.create(parent.prototype);
extend(child.prototype, protoProps);
child.prototype.constructor = child;
child.super = parent.prototype;
return child;
};
AdsBypasserError.super = null;
_.AdsBypasserError = AdsBypasserError;
function any (c, fn) {
if (c.some) {
return c.some(fn);
}
if (typeof c.length === 'number') {
return Array.prototype.some.call(c, fn);
}
return Object.keys(c).some(function (k) {
return fn(c[k], k, c);
});
}
function all (c, fn) {
if (c.every) {
return c.every(fn);
}
if (typeof c.length === 'number') {
return Array.prototype.every.call(c, fn);
}
return Object.keys(c).every(function (k) {
return fn(c[k], k, c);
});
}
function each (c, fn) {
if (c.forEach) {
c.forEach(fn);
} else if (typeof c.length === 'number') {
Array.prototype.forEach.call(c, fn);
} else {
Object.keys(c).forEach(function (k) {
fn(c[k], k, c);
});
}
}
function map (c, fn) {
if (c.map) {
return c.map(fn);
}
if (typeof c.length === 'number') {
return Array.prototype.map.call(c, fn);
}
return Object.keys(c).map(function (k) {
return fn(c[k], k, c);
});
}
function extend(c) {
Array.prototype.slice.call(arguments, 1).forEach(function (source) {
if (!source) {
return;
}
_.C(source).each(function (v, k) {
c[k] = v;
});
});
return c;
}
function CollectionProxy (collection) {
this._c = collection;
}
CollectionProxy.prototype.size = function () {
if (typeof this._c.length === 'number') {
return this._c.length;
}
return Object.keys(c).length;
};
CollectionProxy.prototype.at = function (k) {
return this._c[k];
};
CollectionProxy.prototype.each = function (fn) {
each(this._c, fn);
return this;
};
CollectionProxy.prototype.find = function (fn) {
var result;
any(this._c, function (value, index, self) {
var tmp = fn(value, index, self);
if (tmp !== _.none) {
result = {
key: index,
value: value,
payload: tmp,
};
return true;
}
return false;
});
return result;
};
CollectionProxy.prototype.all = function (fn) {
return all(this._c, fn);
};
CollectionProxy.prototype.map = function (fn) {
return map(this._c, fn);
};
_.C = function (collection) {
return new CollectionProxy(collection);
};
_.T = function (s) {
if (typeof s === 'string') {
} else if (s instanceof String) {
s = s.toString();
} else {
throw new AdsBypasserError('template must be a string');
}
var T = {
'{{': '{',
'}}': '}',
};
return function () {
var args = Array.prototype.slice.call(arguments);
var kwargs = args[args.length-1];
return s.replace(/\{\{|\}\}|\{([^\}]+)\}/g, function (m, key) {
if (T.hasOwnProperty(m)) {
return T[m];
}
if (args.hasOwnProperty(key)) {
return args[key];
}
if (kwargs.hasOwnProperty(key)) {
return kwargs[key];
}
return m;
});
};
};
_.P = function (fn) {
if (typeof fn !== 'function') {
throw new _.AdsBypasserError('must give a function');
}
var slice = Array.prototype.slice;
var args = slice.call(arguments, 1);
return function () {
return fn.apply(this, args.concat(slice.call(arguments)));
};
};
_.D = function (fn) {
return new Promise(fn);
};
_.parseJSON = function (json) {
try {
return JSON.parse(json);
} catch (e) {
_.warn(e);
}
return _.none;
};
_.isString = function (value) {
return (typeof value === 'string') || (value instanceof String);
};
_.nop = function () {
};
_.none = _.nop;
function log (method, args) {
if (_._quiet) {
return;
}
args = Array.prototype.slice.call(args);
if (_.isString(args[0])) {
args[0] = 'AdsBypasser: ' + args[0];
} else {
args.unshift('AdsBypasser:');
}
var f = console[method];
if (typeof f === 'function') {
f.apply(console, args);
}
}
_._quiet = false;
_.info = function () {
log('info', arguments);
};
_.warn = function () {
log('warn', arguments);
};
return _;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context) {
var core = require('./core.js');
return factory(context, core);
};
} else {
context.$ = factory(context, context._);
}
}(this, function (context, _) {
'use strict';
var window = context.window;
var document = window.document;
var DomNotFoundError = _.AdsBypasserError.extend({
name: 'DomNotFoundError',
constructor: function (selector) {
DomNotFoundError.super.constructor.call(this, _.T('`{0}` not found')(selector));
},
});
var $ = function (selector, context) {
if (!context || !context.querySelector) {
context = document;
}
var n = context.querySelector(selector);
if (!n) {
throw new DomNotFoundError(selector);
}
return n;
};
$.$ = function (selector, context) {
try {
return $(selector, context);
} catch (e) {
return null;
}
};
$.$$ = function (selector, context) {
if (!context || !context.querySelectorAll) {
context = document;
}
var ns = context.querySelectorAll(selector);
return _.C(ns);
};
$.toDOM = function(rawHTML) {
try {
var parser = new DOMParser();
var DOMHTML = parser.parseFromString(rawHTML, "text/html");
return DOMHTML;
} catch (e) {
throw new _.AdsBypasserError('could not parse HTML to DOM');
}
};
$.removeNodes = function (selector, context) {
$.$$(selector, context).each(function (e) {
e.parentNode.removeChild(e);
});
};
function searchScriptsByRegExp (pattern, context) {
var m = $.$$('script', context).find(function (s) {
var m = s.innerHTML.match(pattern);
if (!m) {
return _.none;
}
return m;
});
if (!m) {
return null;
}
return m.payload;
}
function searchScriptsByString (pattern, context) {
var m = $.$$('script', context).find(function (s) {
var m = s.innerHTML.indexOf(pattern);
if (m < 0) {
return _.none;
}
return m;
});
if (!m) {
return null;
}
return m.value.innerHTML;
}
$.searchScripts = function (pattern, context) {
if (pattern instanceof RegExp) {
return searchScriptsByRegExp(pattern, context);
} else if (_.isString(pattern)) {
return searchScriptsByString(pattern, context);
} else {
return null;
}
};
return $;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context, GM) {
var core = require('./core.js');
return factory(context, GM, core);
};
} else {
factory(context, {
xmlhttpRequest: GM_xmlhttpRequest,
}, context._);
}
}(this, function (context, GM, _) {
'use strict';
var window = context.window;
var document = window.document;
var $ = context.$ || {};
function deepJoin (prefix, object) {
return _.C(object).map(function (v, k) {
var key = _.T('{0}[{1}]')(prefix, k);
if (typeof v === 'object') {
return deepJoin(key, v);
}
return _.T('{0}={1}').apply(this, [key, v].map(encodeURIComponent));
}).join('&');
}
function toQuery (data) {
var type = typeof data;
if (data === null || (type !== 'string' && type !== 'object')) {
return '';
}
if (type === 'string') {
return data;
}
if (data instanceof String) {
return data.toString();
}
return _.C(data).map(function (v, k) {
if (typeof v === 'object') {
return deepJoin(k, v);
}
return _.T('{0}={1}').apply(this, [k, v].map(encodeURIComponent));
}).join('&');
}
function ajax (method, url, data, headers) {
var l = document.createElement('a');
l.href = url;
var reqHost = l.hostname;
var overrideHeaders = {
Host: reqHost || window.location.host,
Origin: window.location.origin,
Referer: window.location.href,
'X-Requested-With': 'XMLHttpRequest',
};
_.C(overrideHeaders).each(function (v, k, c) {
if (headers[k] === _.none) {
delete headers[k];
} else {
headers[k] = v;
}
});
var xhr = null;
var promise = _.D(function (resolve, reject) {
xhr = GM.xmlhttpRequest({
method: method,
url: url,
data: data,
headers: headers,
onload: function (response) {
response = (typeof response.responseText !== 'undefined') ? response : this;
if (response.status !== 200) {
reject(response.responseText);
} else {
resolve(response.responseText);
}
},
onerror: function (response) {
response = (typeof response.responseText !== 'undefined') ? response : this;
reject(response.responseText);
},
});
});
promise.abort = function () {
xhr.abort();
};
return promise;
}
$.get = function (url, data, headers) {
data = toQuery(data);
data = data ? '?' + data : '';
headers = headers || {};
return ajax('GET', url + data, '', headers);
};
$.post = function (url, data, headers) {
data = toQuery(data);
var h = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Content-Length': data.length,
};
if (headers) {
_.C(headers).each(function (v, k) {
h[k] = v;
});
}
return ajax('POST', url, data, h);
};
return $;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context) {
var core = require('./core.js');
return factory(context, core);
};
} else {
factory(context, context._);
}
}(this, function (context, _) {
'use strict';
var window = context.window;
var document = window.document;
var $ = context.$ || {};
$.setCookie = function (key, value) {
var now = new Date();
now.setTime(now.getTime() + 3600 * 1000);
var tpl = _.T('{0}={1};path=/;');
document.cookie = tpl(key, value, now.toUTCString());
};
$.getCookie = function (key) {
var c = _.C(document.cookie.split(';')).find(function (v) {
var k = v.replace(/^\s*(\w+)=.+$/, '$1');
if (k !== key) {
return _.none;
}
});
if (!c) {
return null;
}
c = c.value.replace(/^\s*\w+=([^;]+).+$/, '$1');
if (!c) {
return null;
}
return c;
};
$.resetCookies = function () {
var a = document.domain;
var b = document.domain.replace(/^www\./, '');
var c = document.domain.replace(/^(\w+\.)+?(\w+\.\w+)$/, '$2');
var d = (new Date(1e3)).toUTCString();
_.C(document.cookie.split(';')).each(function (v) {
var k = v.replace(/^\s*(\w+)=.+$/, '$1');
document.cookie = _.T('{0}=;expires={1};')(k, d);
document.cookie = _.T('{0}=;path=/;expires={1};')(k, d);
var e = _.T('{0}=;path=/;domain={1};expires={2};');
document.cookie = e(k, a, d);
document.cookie = e(k, b, d);
document.cookie = e(k, c, d);
});
};
return $;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context) {
var core = require('./core.js');
return factory(context, core);
};
} else {
factory(context, context._);
}
}(this, function (context, _) {
'use strict';
var window = context.window;
var document = window.document;
var $ = context.$ || {};
var patterns = [];
$.register = function (pattern) {
patterns.push(pattern);
};
function dispatchByObject (rule, url_6) {
var matched = {};
var passed = _.C(rule).all(function (pattern, part) {
if (pattern instanceof RegExp) {
matched[part] = url_6[part].match(pattern);
} else if (pattern instanceof Array) {
var r = _.C(pattern).find(function (p) {
var m = url_6[part].match(p);
return m || _.none;
});
matched[part] = r ? r.payload : null;
}
return !!matched[part];
});
return passed ? matched : null;
}
function dispatchByRegExp (rule, url_1) {
return url_1.match(rule);
}
function dispatchByArray (byLocation, rules, url_1, url_3, url_6) {
var tmp = _.C(rules).find(function (rule) {
var m = dispatch(byLocation, rule, url_1, url_3, url_6);
if (!m) {
return _.none;
}
return m;
});
return tmp ? tmp.payload : null;
}
function dispatchByString (rule, url_3) {
var scheme = /\*|https?|file|ftp|chrome-extension/;
var host = /\*|(\*\.)?([^\/*]+)/;
var path = /\/.*/;
var up = new RegExp(_.T('^({scheme})://({host})?({path})$')({
scheme: scheme.source,
host: host.source,
path: path.source,
}));
var matched = rule.match(up);
if (!matched) {
return null;
}
scheme = matched[1];
host = matched[2];
var wc = matched[3];
var sd = matched[4];
path = matched[5];
if (scheme === '*' && !/https?/.test(url_3.scheme)) {
return null;
} else if (scheme !== url_3.scheme) {
return null;
}
if (scheme !== 'file' && host !== '*') {
if (wc) {
up = url_3.host.indexOf(sd);
if (up < 0 || up + sd.length !== url_3.host.length) {
return null;
}
} else if (host !== url_3.host) {
return null;
}
}
path = new RegExp(_.T('^{0}$')(path.replace(/[*.\[\]?+#]/g, function (c) {
if (c === '*') {
return '.*';
}
return '\\' + c;
})));
if (!path.test(url_3.path)) {
return null;
}
return url_3;
}
function dispatchByFunction (rule, url_1, url_3, url_6) {
return rule(url_1, url_3, url_6);
}
function dispatch (byLocation, rule, url_1, url_3, url_6) {
if (rule instanceof Array) {
return dispatchByArray(byLocation, rule, url_1, url_3, url_6);
}
if (typeof rule === 'function') {
if (byLocation) {
return null;
}
return dispatchByFunction(rule, url_1, url_3, url_6);
}
if (rule instanceof RegExp) {
return dispatchByRegExp(rule, url_1);
}
if (_.isString(rule)) {
return dispatchByString(rule, url_3);
}
return dispatchByObject(rule, url_6);
}
$._findHandler = function (byLocation) {
var url_1 = window.location.toString();
var url_3 = {
scheme: window.location.protocol.slice(0, -1),
host: window.location.host,
path: window.location.pathname + window.location.search + window.location.hash,
};
var url_6 = {
scheme: window.location.protocol,
host: window.location.hostname,
port: window.location.port,
path: window.location.pathname,
query: window.location.search,
hash: window.location.hash,
};
var pattern = _.C(patterns).find(function (pattern) {
var m = dispatch(byLocation, pattern.rule, url_1, url_3, url_6);
if (!m) {
return _.none;
}
return m;
});
if (!pattern) {
return null;
}
var matched = pattern.payload;
pattern = pattern.value;
if (!pattern.start && !pattern.ready) {
return null;
}
return {
start: pattern.start ? _.P(pattern.start, matched) : _.nop,
ready: pattern.ready ? _.P(pattern.ready, matched) : _.nop,
};
};
return $;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context) {
var core = require('./core.js');
return factory(context, core);
};
} else {
factory(context, context._);
}
}(this, function (context, _) {
'use strict';
var window = context.window;
var document = window.document;
var $ = context.$ || {};
function prepare (e) {
if (!document.body) {
document.body = document.createElement('body');
}
document.body.appendChild(e);
}
function get (url) {
var a = document.createElement('a');
a.href = url;
prepare(a);
a.click();
}
function post (path, params) {
params = params || {};
var form = document.createElement('form');
form.method = 'post';
form.action = path;
_.C(params).each(function (value, key) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = value;
form.appendChild(input);
});
prepare(form);
form.submit();
}
$.openLink = function (to, options) {
if (!_.isString(to) && !to) {
_.warn('false URL');
return;
}
options = options || {};
var withReferer = typeof options.referer === 'undefined' ? true : options.referer;
var postData = options.post;
var from = window.location.toString();
_.info(_.T('{0} -> {1}')(from, to));
if (postData) {
post(to, postData);
return;
}
if (withReferer) {
get(to);
return;
}
window.top.location.replace(to);
};
return $;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context) {
var core = require('./core.js');
var ajax = require('./ajax.js');
var $ = ajax(context);
return factory(context, core, $);
};
} else {
factory(context, context._, context.$);
}
}(this, function (context, _, $) {
'use strict';
var window = context.window;
var unsafeWindow = context.unsafeWindow || (0, eval)('this').window;
var document = window.document;
$.removeAllTimer = function () {
var handle = window.setInterval(_.nop, 10);
while (handle > 0) {
window.clearInterval(handle--);
}
handle = window.setTimeout(_.nop, 10);
while (handle > 0) {
window.clearTimeout(handle--);
}
};
$.captcha = function (imgSrc, cb) {
if (!$.config.externalServerSupport) {
return;
}
var a = document.createElement('canvas');
var b = a.getContext('2d');
var c = new Image();
c.src = imgSrc;
c.onload = function () {
a.width = c.width;
a.height = c.height;
b.drawImage(c, 0, 0);
var d = a.toDataURL();
var e = d.substr(d.indexOf(',') + 1);
$.post('http://www.wcpan.info/cgi-bin/captcha.cgi', {
i: e,
}, cb);
};
};
function clone (safe) {
if (safe === null || !(safe instanceof Object)) {
return safe;
}
if (safe instanceof String) {
return safe.toString();
}
if (safe instanceof Function) {
return exportFunction(safe, unsafeWindow, {
allowCrossOriginArguments: true,
});
}
if (safe instanceof Array) {
var unsafe = new unsafeWindow.Array();
for (var i = 0; i < safe.length; ++i) {
unsafe.push(clone(safe[i]));
}
return unsafe;
}
var unsafe = new unsafeWindow.Object();
_.C(safe).each(function (v, k) {
unsafe[k] = clone(v);
});
return unsafe;
}
var MAGIC_KEY = '__adsbypasser_reverse_proxy__';
$.window = (function () {
var isFirefox = typeof InstallTrigger !== 'undefined';
if (!isFirefox) {
return unsafeWindow;
}
var decorator = {
set: function (target, key, value) {
if (key === MAGIC_KEY) {
return false;
}
if (target === unsafeWindow && key === 'open') {
var d = Object.getOwnPropertyDescriptor(target, key);
d.value = clone(value);
Object.defineProperty(target, key, d);
} else {
target[key] = clone(value);
}
return true;
},
get: function (target, key) {
if (key === MAGIC_KEY) {
return target;
}
var value = target[key];
var type = typeof value;
if (value === null || (type !== 'function' && type !== 'object')) {
return value;
}
return new Proxy(value, decorator);
},
apply: function (target, self, args) {
args = Array.prototype.slice.call(args);
if (target === unsafeWindow.Object.defineProperty) {
args[0] = args[0][MAGIC_KEY];
}
if (target === unsafeWindow.Function.apply) {
self = self[MAGIC_KEY];
args[1] = Array.prototype.slice.call(args[1]);
}
var usargs = clone(args);
return target.apply(self, usargs);
},
construct: function (target, args) {
args = Array.prototype.slice.call(args);
args.unshift(undefined);
var usargs = clone(args);
var bind = unsafeWindow.Function.prototype.bind;
return new (bind.apply(target, usargs));
},
};
return new Proxy(unsafeWindow, decorator);
})();
return $;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context, GM) {
var _ = require('lodash');
var core = require('./core.js');
var misc = require('./misc.js');
var dispatcher = require('./dispatcher.js');
var modules = [misc, dispatcher].map(function (v) {
return v.call(null, context, GM);
});
var $ = _.assign.apply(null, modules);
return factory(context, GM, core, $);
};
} else {
factory(context, {
getValue: GM_getValue,
setValue: GM_setValue,
}, context._, context.$);
}
}(this, function (context, GM, _, $) {
'use strict';
var MANIFEST = [
{
name: 'version',
key: 'version',
default_: 0,
verify: function (v) {
return typeof v === 'number' && v >= 0;
},
},
{
name: 'alignCenter',
key: 'align_center',
default_: true,
verify: isBoolean,
},
{
name: 'changeBackground',
key: 'change_background',
default_: true,
verify: isBoolean,
},
{
name: 'externalServerSupport',
key: 'external_server_support',
default_: false,
verify: isBoolean,
},
{
name: 'redirectImage',
key: 'redirect_image',
default_: true,
verify: isBoolean,
},
{
name: 'scaleImage',
key: 'scale_image',
default_: true,
verify: isBoolean,
},
{
name: 'logLevel',
key: 'log_level',
default_: 1,
verify: function (v) {
return typeof v === 'number' && v >= 0 && v <= 2;
},
},
];
var PATCHES = [
function (c) {
var ac = typeof c.alignCenter === 'boolean';
if (typeof c.changeBackground !== 'boolean') {
c.changeBackground = ac ? c.alignCenter : true;
}
if (typeof c.scaleImage !== 'boolean') {
c.scaleImage = ac ? c.alignCenter : true;
}
if (!ac) {
c.alignCenter = true;
}
if (typeof c.redirectImage !== 'boolean') {
c.redirectImage = true;
}
},
function (c) {
if (typeof c.externalServerSupport !== 'boolean') {
c.externalServerSupport = false;
}
},
function (c) {
if (typeof c.logLevel !== 'number') {
c.logLevel = 1;
}
},
];
var window = context.window;
function isBoolean(v) {
return typeof v === 'boolean';
}
function createConfig () {
var c = {};
_.C(MANIFEST).each(function (m) {
Object.defineProperty(c, m.name, {
configurable: true,
enumerable: true,
get: function () {
return GM.getValue(m.key, m.default_);
},
set: function (v) {
GM.setValue(m.key, v);
},
});
});
return c;
}
function senityCheck (c) {
var ok = _.C(MANIFEST).all(function (m) {
return m.verify(c[m.name]);
});
if (!ok) {
c.version = 0;
}
return c;
}
function migrate (c) {
while (c.version < PATCHES.length) {
PATCHES[c.version](c);
++c.version;
}
return c;
}
$.config = migrate(senityCheck(createConfig()));
$.register({
rule: {
host: /^adsbypasser\.github\.io$/,
path: /^\/configure\.html$/,
},
ready: function () {
$.window.commit = function (data) {
data.version = $.config.version;
_.C(data).each(function (v, k) {
$.config[k] = v;
});
};
$.window.render({
version: $.config.version,
options: {
alignCenter: {
type: 'checkbox',
value: $.config.alignCenter,
label: 'Align Center',
help: 'Align image to the center if possible. (default: enabled)',
},
changeBackground: {
type: 'checkbox',
value: $.config.changeBackground,
label: 'Change Background',
help: 'Use Firefox-like image background if possible. (default: enabled)',
},
redirectImage: {
type: 'checkbox',
value: $.config.redirectImage,
label: 'Redirect Image',
help: [
'Directly open image link if possible. (default: enabled)',
'If disabled, redirection will only works on link shortener sites.',
].join('
\n'),
},
scaleImage: {
type: 'checkbox',
value: $.config.scaleImage,
label: 'Scale Image',
help: 'When image loaded, scale it to fit window if possible. (default: enabled)',
},
externalServerSupport: {
type: 'checkbox',
value: $.config.externalServerSupport,
label: 'External Server Support',
help: [
'Send URL information to external server to enhance features (e.g.: captcha resolving). (default: disabled)',
'Affected sites:',
'setlinks.us (captcha)',
].join('
\n'),
},
logLevel: {
type: 'select',
value: $.config.logLevel,
menu: [
[0, '0 (quiet)'],
[1, '1 (default)'],
[2, '2 (verbose)'],
],
label: 'Log Level',
help: [
'Log level in developer console. (default: 1)',
'0 will not print anything in console.',
'1 will only print logs on affected sites.',
'2 will print on any sites.',
].join('
\n'),
},
},
});
},
});
return $;
}));
(function (context, factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = function (context, GM) {
var _ = require('lodash');
var core = require('./core.js');
var dom = require('./dom.js');
var config = require('./config.js');
var link = require('./link.js');
var misc = require('./misc.js');
var modules = [dom, config, link, misc].map(function (v) {
return v.call(null, context, GM);
});
var $ = _.assign.apply(_, modules);
return factory(context, GM, core, $);
};
} else {
factory(context, {
getResourceText: GM_getResourceText,
addStyle: GM_addStyle,
getResourceURL: GM_getResourceURL,
}, context._, context.$);
}
}(this, function (context, GM, _, $) {
'use strict';
var window = context.window;
var document = window.document;
$.openImage = function (imgSrc, options) {
options = options || {};
var replace = !!options.replace;
var referer = !!options.referer;
if (replace) {
replaceBody(imgSrc);
return;
}
if ($.config.redirectImage) {
$.openLink(imgSrc, {
referer: referer,
});
}
};
function enableScrolling () {
var o = document.compatMode === 'CSS1Compat' ? document.documentElement : document.body;
o.style.overflow = '';
};
function toggleShrinking () {
this.classList.toggle('adsbypasser-shrinked');
}
function checkScaling () {
var nw = this.naturalWidth;
var nh = this.naturalHeight;
var cw = document.documentElement.clientWidth;
var ch = document.documentElement.clientHeight;
if ((nw > cw || nh > ch) && !this.classList.contains('adsbypasser-resizable')) {
this.classList.add('adsbypasser-resizable');
this.classList.add('adsbypasser-shrinked');
this.addEventListener('click', toggleShrinking);
} else {
this.removeEventListener('click', toggleShrinking);
this.classList.remove('adsbypasser-shrinked');
this.classList.remove('adsbypasser-resizable');
}
}
function scaleImage (i) {
var style = GM.getResourceText('scaleImage');
GM.addStyle(style);
if (i.naturalWidth && i.naturalHeight) {
checkScaling.call(i);
} else {
i.addEventListener('load', checkScaling);
}
var h;
window.addEventListener('resize', function () {
window.clearTimeout(h);
h = window.setTimeout(checkScaling.bind(i), 100);
});
}
function changeBackground () {
var bgImage = GM.getResourceURL('bgImage');
document.body.style.backgroundColor = '#222222';
document.body.style.backgroundImage = _.T('url(\'{0}\')')(bgImage);
}
function alignCenter () {
var style = GM.getResourceText('alignCenter');
GM.addStyle(style);
}
function injectStyle (d, i) {
$.removeNodes('style, link[rel=stylesheet]');
d.id = 'adsbypasser-wrapper';
i.id = 'adsbypasser-image';
}
function replaceBody (imgSrc) {
if (!$.config.redirectImage) {
return;
}
if (!imgSrc) {
_.warn('false url');
return;
}
_.info(_.T('replacing body with `{0}` ...')(imgSrc));
$.removeAllTimer();
enableScrolling();
document.body = document.createElement('body');
var d = document.createElement('div');
document.body.appendChild(d);
var i = document.createElement('img');
i.src = imgSrc;
d.appendChild(i);
if ($.config.alignCenter || $.config.scaleImage) {
injectStyle(d, i);
}
if ($.config.alignCenter) {
alignCenter();
}
if ($.config.changeBackground) {
changeBackground();
}
if ($.config.scaleImage) {
scaleImage(i);
}
};
return $;
}));
$.register({
rule: {
host: /^www\.4shared\.com$/,
path: /^\/(mp3|get|rar|zip|file|android|software|program)\//,
},
ready: function () {
'use strict';
$.get('http://www.4server.info/find.php', {
data: window.location.href,
}).then(function (data) {
var d = $.toDOM(data);
var c = $('meta[http-equiv=refresh]', d);
var b = c.content.match(/URL=(.+)$/);
var a = b[1];
$.openLink(a);
});
},
});
$.register({
rule: {
host: /^(www\.)?arab\.sh$/,
path: /^\/\w+$/,
},
ready: function () {
'use strict';
var f = $('form[name=F1]');
setTimeout(function() {
f.submit();
}, 20000);
},
});
$.register({
rule: {
host: /^(www\.)?coolrom\.com$/,
path: /^\/dlpop\.php$/,
},
ready: function () {
'use strict';
var matches = $.searchScripts(/