Skip to content

Instantly share code, notes, and snippets.

@version365
Last active February 9, 2020 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save version365/7b4e7e20dabc7812cf0e692371cbceaf to your computer and use it in GitHub Desktop.
Save version365/7b4e7e20dabc7812cf0e692371cbceaf to your computer and use it in GitHub Desktop.
Redirector based on AdsBypasser
// ==UserScript==
// @name Redirev
// @namespace Redirev
// @description Redirecting websites based on url. Trying to replace the Redirector extension as much as possible.
// @version 365
// @copyright Version Kinda
// @based-on AdsBypasser
// @license BSD
// @icon https://raw.githubusercontent.com/version365/365uploads/master/Redirev.png
// @grant GM_deleteValue
// @grant GM_getResourceURL
// @grant GM_getValue
// @grant GM_openInTab
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM.deleteValue
// @grant GM.getResourceUrl
// @grant GM.getValue
// @grant GM.openInTab
// @grant GM.setValue
// @grant GM.xmlHttpRequest
// @grant unsafeWindow
// @run-at document-start
// @include http://*
// @include https://*
// @connect *
// ==/UserScript==
(function(modules) {
var installedModules = {};
function __webpack_require__(moduleId) {
if(installedModules[moduleId]) {
return installedModules[moduleId].exports;
}
var module = installedModules[moduleId] = {
i: moduleId,
l: false,
exports: {}
};
modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
module.l = true;
return module.exports;
}
__webpack_require__.m = modules;
__webpack_require__.c = installedModules;
__webpack_require__.d = function(exports, name, getter) {
if(!__webpack_require__.o(exports, name)) {
Object.defineProperty(exports, name, {
configurable: false,
enumerable: true,
get: getter
});
}
};
__webpack_require__.r = function(exports) {
Object.defineProperty(exports, '__esModule', { value: true });
};
__webpack_require__.n = function(module) {
var getter = module && module.__esModule ?
function getDefault() { return module['default']; } :
function getModuleExports() { return module; };
__webpack_require__.d(getter, 'a', getter);
return getter;
};
__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
__webpack_require__.p = "";
return __webpack_require__(__webpack_require__.s = 0);
})
([
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
var util_dispatcher__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
var util_platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
var util_config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4);
var util_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
var _REDIREV_HANDLERS___WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6);
const isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
function disableWindowOpen () {
util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].open = function () {
return {
closed: false,
};
};
util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].alert = util_core__WEBPACK_IMPORTED_MODULE_0__["nop"];
util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].confirm = util_core__WEBPACK_IMPORTED_MODULE_0__["nop"];
}
function disableLeavePrompt (element) {
if (!element) {
return;
}
const seal = {
set: function () {
Object(util_logger__WEBPACK_IMPORTED_MODULE_4__["info"])('blocked onbeforeunload');
},
};
element.onbeforeunload = undefined;
if (isSafari) {
element.__defineSetter__('onbeforeunload', seal.set);
} else {
util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].Object.defineProperty(element, 'onbeforeunload', {
configurable: true,
enumerable: false,
get: undefined,
set: seal.set,
});
}
const oael = element.addEventListener;
const nael = function (type) {
if (type === 'beforeunload') {
Object(util_logger__WEBPACK_IMPORTED_MODULE_4__["info"])('blocked addEventListener onbeforeunload');
return;
}
return oael.apply(this, arguments);
};
element.addEventListener = nael;
}
function changeTitle () {
document.title += ' - Redirev';
}
async function beforeDOMReady (handler) {
const config = await Object(util_config__WEBPACK_IMPORTED_MODULE_3__["dumpConfig"])();
Object(util_logger__WEBPACK_IMPORTED_MODULE_4__["info"])('working on\n%s \nwith\n%s', window.location.toString(), JSON.stringify(config));
disableLeavePrompt(util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"]);
disableWindowOpen();
await handler.start();
}
async function afterDOMReady (handler) {
disableLeavePrompt(util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].document.body);
changeTitle();
await handler.ready();
}
function waitDOM () {
return new Promise((resolve) => {
if (document.readyState !== 'loading') {
resolve();
return;
}
document.addEventListener('DOMContentLoaded', () => {
resolve();
});
});
}
async function main () {
if (util_platform__WEBPACK_IMPORTED_MODULE_2__["rawUSW"].top !== util_platform__WEBPACK_IMPORTED_MODULE_2__["rawUSW"].self) {
return;
}
util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].registerMenuCommand('\(not applicable\)', () => {
util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].openInTab('https://redirev.io/configure.html'); //putting non-existent website to not auto-update//
});
await Object(util_config__WEBPACK_IMPORTED_MODULE_3__["loadConfig"])();
const handler = Object(util_dispatcher__WEBPACK_IMPORTED_MODULE_1__["findHandler"])();
if (handler) {
await beforeDOMReady(handler);
await waitDOM();
await afterDOMReady(handler);
return;
}
}
main().catch((e) => {
Object(util_logger__WEBPACK_IMPORTED_MODULE_4__["warn"])(e);
});
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "RedirevError", function() { return RedirevError; });
__webpack_require__.d(__webpack_exports__, "every", function() { return every; });
__webpack_require__.d(__webpack_exports__, "find", function() { return find; });
__webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
__webpack_require__.d(__webpack_exports__, "isString", function() { return isString; });
__webpack_require__.d(__webpack_exports__, "map", function() { return map; });
__webpack_require__.d(__webpack_exports__, "none", function() { return none; });
__webpack_require__.d(__webpack_exports__, "nop", function() { return nop; });
__webpack_require__.d(__webpack_exports__, "partial", function() { return partial; });
__webpack_require__.d(__webpack_exports__, "tryEvery", function() { return tryEvery; });
__webpack_require__.d(__webpack_exports__, "wait", function() { return wait; });
class RedirevError extends Error {
constructor (message) {
super(message);
}
get name () {
return 'RedirevError';
}
}
function forEach (collection, fn) {
if (isArrayLike(collection)) {
return Array.prototype.forEach.call(collection, fn);
}
return Object.keys(collection).forEach((k) => {
return fn(collection[k], k, collection);
});
}
function every (collection, fn) {
if (isArrayLike(collection)) {
return Array.prototype.every.call(collection, fn);
}
return Object.keys(collection).every((k) => {
return fn(collection[k], k, collection);
});
}
function map (collection, fn) {
if (isArrayLike(collection)) {
return Array.prototype.map.call(collection, fn);
}
const mapped = Object.assign({}, collection);
Object.getOwnPropertyNames(mapped).forEach((k) => {
mapped[k] = fn(collection[k], k, collection);
});
return mapped;
}
function find (collection, fn) {
for (const [k, v] of enumerate(collection)) {
const r = fn(v, k, collection);
if (r !== none) {
return [k, v, r];
}
}
return [none, none, none];
}
function * enumerate (collection) {
if (isArrayLike(collection)) {
yield * Array.prototype.entries.call(collection);
return;
}
const keys = Object.getOwnPropertyNames(collection);
for (const k of keys) {
yield [k, collection[k]];
}
}
function isArrayLike (collection) {
return Array.isArray(collection) || isNodeList(collection);
}
function isNodeList (collection) {
return collection.constructor.name === 'NodeList';
}
function partial (fn, ...args) {
if (typeof fn !== 'function') {
throw new RedirevError('must give a function');
}
return (...innerArgs) => {
return fn(...args.concat(innerArgs));
};
}
function isString (value) {
return (typeof value === 'string') || (value instanceof String);
}
function nop () {
}
const none = nop;
function wait (msDelay) {
return new Promise((resolve) => {
setTimeout(resolve, msDelay);
});
}
function tryEvery (msInterval, fn) {
return new Promise((resolve) => {
const handle = setInterval(function () {
const result = fn();
if (result !== none) {
clearInterval(handle);
resolve(result);
}
}, msInterval);
});
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "register", function() { return register; });
__webpack_require__.d(__webpack_exports__, "findHandler", function() { return findHandler; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
const patterns = [];
function register (pattern) {
patterns.push(pattern);
}
function dispatchByObject (rule, url_6) {
const matched = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["map"])(rule, (pattern, part) => {
if (pattern instanceof RegExp) {
return url_6[part].match(pattern);
}
if (Array.isArray(pattern)) {
const [, , r] = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["find"])(pattern, (sp) => {
const m = url_6[part].match(sp);
return m || util_core__WEBPACK_IMPORTED_MODULE_0__["none"];
});
return r !== util_core__WEBPACK_IMPORTED_MODULE_0__["none"] ? r : null;
}
throw new util_core__WEBPACK_IMPORTED_MODULE_0__["RedirevError"]('invalid rule');
});
const passed = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["every"])(matched, (v) => {
return !!v;
});
return passed ? matched : null;
}
function dispatchByRegExp (rule, url_1) {
return url_1.match(rule);
}
function dispatchByArray (rules, url_1, url_3, url_6) {
const [, , r] = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["find"])(rules, (rule) => {
const m = dispatch(rule, url_1, url_3, url_6);
return m ? m : util_core__WEBPACK_IMPORTED_MODULE_0__["none"];
});
return r !== util_core__WEBPACK_IMPORTED_MODULE_0__["none"] ? r : null;
}
function dispatchByString (rule, url_3) {
let scheme = /\*|https?|file|ftp|chrome-extension/;
let host = /\*|(\*\.)?([^/*]+)/;
let path = /\/.*/;
let tmp = `^(${scheme.source})://(${host.source})?(${path.source})$`;
let up = new RegExp(tmp);
const matched = rule.match(up);
if (!matched) {
return null;
}
scheme = matched[1];
host = matched[2];
const wc = matched[3];
const sd = matched[4];
path = matched[5];
if (scheme === '*' && !/https?/.test(url_3.scheme)) {
return null;
}
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;
}
}
tmp = path.replace(/[*.[\]?+#]/g, (c) => {
if (c === '*') {
return '.*';
}
return '\\' + c;
});
path = new RegExp(`^${tmp}$`);
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 (rule, url_1, url_3, url_6) {
if (Array.isArray(rule)) {
return dispatchByArray(rule, url_1, url_3, url_6);
}
if (typeof rule === 'function') {
return dispatchByFunction(rule, url_1, url_3, url_6);
}
if (rule instanceof RegExp) {
return dispatchByRegExp(rule, url_1);
}
if (Object(util_core__WEBPACK_IMPORTED_MODULE_0__["isString"])(rule)) {
return dispatchByString(rule, url_3);
}
return dispatchByObject(rule, url_6);
}
function findHandler () {
const url_1 = window.location.toString();
const url_3 = {
scheme: window.location.protocol.slice(0, -1),
host: window.location.host,
path: window.location.pathname + window.location.search + window.location.hash,
};
const 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,
};
const [i, pattern, matched] = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["find"])(patterns, (pattern) => {
const m = dispatch(pattern.rule, url_1, url_3, url_6);
return m ? m : util_core__WEBPACK_IMPORTED_MODULE_0__["none"];
});
if (i === util_core__WEBPACK_IMPORTED_MODULE_0__["none"]) {
return null;
}
if (!pattern.start && !pattern.ready) {
return null;
}
return {
start: pattern.start ? Object(util_core__WEBPACK_IMPORTED_MODULE_0__["partial"])(pattern.start, matched) : util_core__WEBPACK_IMPORTED_MODULE_0__["nop"],
ready: pattern.ready ? Object(util_core__WEBPACK_IMPORTED_MODULE_0__["partial"])(pattern.ready, matched) : util_core__WEBPACK_IMPORTED_MODULE_0__["nop"],
};
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "rawUSW", function() { return rawUSW; });
__webpack_require__.d(__webpack_exports__, "usw", function() { return usw; });
__webpack_require__.d(__webpack_exports__, "GMAPI", function() { return GMAPI; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
const rawUSW = getUnsafeWindow();
const usw = getUnsafeWindowProxy();
const GMAPI = getGreaseMonkeyAPI();
function getUnsafeWindow () {
let w = null;
try {
w = unsafeWindow;
} catch (e) {
try {
w = (0, eval)('this').global;
} catch (e) {
}
}
return w ? w : (0, eval)('this').window;
}
function getGreaseMonkeyAPI () {
if (rawUSW.global) {
return null;
}
const gm = {};
if (typeof GM_openInTab === 'function') {
gm.openInTab = GM_openInTab;
} else {
gm.openInTab = GM.openInTab;
}
if (typeof GM_getValue === 'function') {
gm.getValue = (name, default_) => {
return Promise.resolve(GM_getValue(name, default_));
};
} else {
gm.getValue = GM.getValue;
}
if (typeof GM_setValue === 'function') {
gm.setValue = (name, value) => {
return Promise.resolve(GM_setValue(name, value));
};
} else {
gm.setValue = GM.setValue;
}
if (typeof GM_deleteValue === 'function') {
gm.deleteValue = (name) => {
return Promise.resolve(GM_deleteValue(name));
};
} else {
gm.deleteValue = GM.deleteValue;
}
if (typeof GM_xmlhttpRequest === 'function') {
gm.xmlHttpRequest = GM_xmlhttpRequest;
} else {
gm.xmlHttpRequest = GM.xmlHttpRequest;
}
if (typeof GM_registerMenuCommand === 'function') {
gm.registerMenuCommand = GM_registerMenuCommand;
} else {
gm.registerMenuCommand = util_core__WEBPACK_IMPORTED_MODULE_0__["nop"];
}
if (typeof GM_getResourceURL === 'function') {
gm.getResourceUrl = (resourceName) => {
return Promise.resolve(GM_getResourceURL(resourceName));
};
} else if (typeof GM === 'object' && GM && GM.getResourceUrl) {
gm.getResourceUrl = GM.getResourceUrl;
}
return gm;
}
const MAGIC_KEY = '__redirev_reverse_proxy__';
function getUnsafeWindowProxy () {
const isFirefox = typeof InstallTrigger !== 'undefined';
const isWebExtension = typeof cloneInto === 'undefined' || typeof exportFunction === 'undefined';
if (!isFirefox || isWebExtension) {
return rawUSW;
}
const decorator = {
set (target, key, value) {
if (key === MAGIC_KEY) {
return false;
}
if (target === unsafeWindow && key === 'open') {
const d = Object.getOwnPropertyDescriptor(target, key);
d.value = clone(function () {
const rv = value();
return cloneInto(rv, unsafeWindow);
});
Object.defineProperty(target, key, d);
} else {
target[key] = clone(value);
}
return true;
},
get (target, key) {
if (key === MAGIC_KEY) {
return target;
}
const value = target[key];
const type = typeof value;
if (value === null || (type !== 'function' && type !== 'object')) {
return value;
}
return new Proxy(value, decorator);
},
apply (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]);
}
if (target === unsafeWindow.document.querySelector) {
self = self[MAGIC_KEY];
}
if (target === unsafeWindow.document.write) {
self = self[MAGIC_KEY];
}
const usargs = clone(args);
return target.apply(self, usargs);
},
construct (target, args) {
args = Array.prototype.slice.call(args);
args.unshift(undefined);
const usargs = clone(args);
const bind = unsafeWindow.Function.prototype.bind;
return new (bind.apply(target, usargs));
},
};
return new Proxy(unsafeWindow, decorator);
}
function clone (safe) {
if (safe === null || !(safe instanceof Object)) {
return safe;
}
if (safe === unsafeWindow) {
return safe;
}
if (safe instanceof String) {
return safe.toString();
}
if (safe instanceof Function) {
return exportFunction(safe, unsafeWindow, {
allowCrossOriginArguments: true,
});
}
if (safe instanceof Array) {
const unsafe = new unsafeWindow.Array();
for (let i = 0; i < safe.length; ++i) {
unsafe.push(clone(safe[i]));
}
return unsafe;
}
const unsafe = new unsafeWindow.Object();
Object(util_core__WEBPACK_IMPORTED_MODULE_0__["forEach"])(safe, (v, k) => {
unsafe[k] = clone(v);
});
return unsafe;
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "dumpConfig", function() { return dumpConfig; });
__webpack_require__.d(__webpack_exports__, "loadConfig", function() { return loadConfig; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
var util_dispatcher__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
var util_platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
const MANIFEST = [
{
key: 'version',
default_: 0,
verify (v) {
return typeof v === 'number' && v >= 0;
},
normalize: toNumber,
},
{
key: 'align_center',
default_: true,
verify: isBoolean,
normalize: toBoolean,
},
{
key: 'change_background',
default_: true,
verify: isBoolean,
normalize: toBoolean,
},
{
key: 'redirect_image',
default_: true,
verify: isBoolean,
normalize: toBoolean,
},
{
key: 'scale_image',
default_: true,
verify: isBoolean,
normalize: toBoolean,
},
{
key: 'log_level',
default_: 1,
verify (v) {
return typeof v === 'number' && v >= 0 && v <= 2;
},
normalize: toNumber,
},
];
const PATCHES = [
async () => {
const alignCenter = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('align_center');
const changeBackground = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('change_background');
const scaleImage = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('scale_image');
const redirectImage = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('redirect_image');
const ac = typeof alignCenter === 'boolean';
if (typeof changeBackground !== 'boolean') {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('change_background', ac ? alignCenter : true);
}
if (typeof scaleImage !== 'boolean') {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('scale_image', ac ? alignCenter : true);
}
if (!ac) {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('align_center', true);
}
if (typeof redirectImage !== 'boolean') {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('redirect_image', true);
}
},
async () => {
const externalServerSupport = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('external_server_support');
if (typeof externalServerSupport !== 'boolean') {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('external_server_support', false);
}
},
async () => {
const logLevel = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('log_level');
if (typeof logLevel !== 'number') {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('log_level', 1);
}
},
async () => {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].deleteValue('external_server_support');
},
];
function isBoolean (v) {
return typeof v === 'boolean';
}
function toBoolean (v) {
return !!v;
}
function toNumber (v) {
return parseInt(v, 10);
}
async function senityCheck () {
let verifyResults = MANIFEST.map(async (descriptor) => {
const rv = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue(descriptor.key);
return descriptor.verify(rv);
});
verifyResults = await Promise.all(verifyResults);
const ok = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["every"])(verifyResults, v => v);
if (!ok) {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('version', 0);
}
}
async function migrate () {
let currentVersion = await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('version');
if (currentVersion !== 0 && !currentVersion) {
throw new util_core__WEBPACK_IMPORTED_MODULE_0__["RedirevError"]('invalid version');
}
while (currentVersion < PATCHES.length) {
PATCHES[currentVersion]();
++currentVersion;
}
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue('version', currentVersion);
}
async function loadConfig () {
await senityCheck();
await migrate();
Object(util_dispatcher__WEBPACK_IMPORTED_MODULE_1__["register"])({
rule: {
host: /^redirev\.io$/, //putting non-existent website to not auto-update//
path: /^\/configure\.html$/,
},
async ready () {
await waitForPage();
util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].commit = async (data) => {
for (const [k, v] of Object.entries(data)) {
await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].setValue(k, v);
}
};
util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].render({
version: await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('version'),
options: {
align_center: {
type: 'checkbox',
value: await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('align_center'),
label: 'Align Center',
help: 'Align image to the center if possible. (default: enabled)',
},
change_background: {
type: 'checkbox',
value: await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('change_background'),
label: 'Change Background',
help: 'Use Firefox-like image background if possible. (default: enabled)',
},
redirect_image: {
type: 'checkbox',
value: await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('redirect_image'),
label: 'Redirect Image',
help: [
'Directly open image link if possible. (default: enabled)',
'If disabled, redirection will only works on link shortener sites.',
].join('<br/>\n'),
},
scale_image: {
type: 'checkbox',
value: await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('scale_image'),
label: 'Scale Image',
help: 'When image loaded, scale it to fit window if possible. (default: enabled)',
},
log_level: {
type: 'select',
value: await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue('log_level'),
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('<br/>\n'),
},
},
});
},
});
}
function waitForPage () {
return new Promise((resolve) => {
const i = setInterval(() => {
if (util_platform__WEBPACK_IMPORTED_MODULE_2__["usw"].render) {
clearInterval(i);
resolve();
}
}, 50);
});
}
async function dumpConfig () {
let rv = MANIFEST.map(async (descriptor) => {
return [descriptor.key, await util_platform__WEBPACK_IMPORTED_MODULE_2__["GMAPI"].getValue(descriptor.key)];
});
rv = await Promise.all(rv);
const o = {};
for (const [k, v] of rv) {
o[k] = v;
}
return o;
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "debug", function() { return debug; });
__webpack_require__.d(__webpack_exports__, "info", function() { return info; });
__webpack_require__.d(__webpack_exports__, "warn", function() { return warn; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
const quiet = false;
function log (method, args) {
if (quiet) {
return;
}
args = Array.prototype.slice.call(args);
if (Object(util_core__WEBPACK_IMPORTED_MODULE_0__["isString"])(args[0])) {
args[0] = 'Redirev: ' + args[0];
} else {
args.unshift('Redirev:');
}
const f = console[method];
if (typeof f === 'function') {
f.apply(console, args);
}
}
function debug () {
log('debug', arguments);
}
function info () {
log('info', arguments);
}
function warn () {
log('warn', arguments);
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
var _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//http to https//
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
scheme: /^http:/,
host: [
/^(www\.)?(clips4sale|imagefap|collegehumor|pornhub|filefactory)\.com$/,
/^(depositfiles|imgbox|katfile|pimpandhost|uptobox|nitroflare)\.com$/,
/^(www\.)?indishare\.me$/,
/^vshare\.io$/,
/^(hitfile|alfafile)\.net$/,
/^itorrents\.org$/,
/^1337x\.\w+$/,
/^sendit\.cloud$/,
],
},
async start () {
let secureProtocol = 'https';
const path = window.location.href.replace(/^[^:]+/, secureProtocol);
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^(www\.)?(buddhabangxxx|black-tgirls)\.com$/,
path: /^\/tour\/content\/\/contentthumbs\/(.+)-1x.jpg/,
},
async start () {
const path = window.location.href.replace('-1x', '-3x');
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^steamcommunity\.com$/,
path: /^\/linkfilter\//,
query: /^\?url=(.+)/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(m.query[1]);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^leechall\.com$/,
path: /^\/redirect\.php/,
query: /^\?(u|url)=(.+)/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(m.query[2]);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^(newsteez|poetriart)\.com$/,
query: /^\?go=(.+)sfurl/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink('https://shrtfly.net/' + m.query[1]);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: [
/^myenemy\.club$/,
/^dares\.xyz$/,
],
query: /^\?go=(.+)sfurl/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink('https://eio.io/' + m.query[1]);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^gslink\.co$/,
path: /^\/e\/(\d+)\/s\/(.+)/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(m.path[2]);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^yespornplease\.com$/,
path: /^\/view\//,
},
async start () {
const path = window.location.href.replace('/view/', '/v/');
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^(www\.)?imagefaq\.info$/,
},
async start () {
const path = window.location.href.replace('faq\.info', 'fap\.com');
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^(www\.)?yourporn\.sexy$/,
},
async start () {
const path = window.location.href.replace('yourporn.sexy', 'sxyprn.com');
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^adf\.ly$/,
},
async start () {
const path = window.location.href.replace('df\.ly', 'y\.gy');
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: [
/^(cut-urls|shrtfly|srtfly|shortzon|mawdok|cut4links|tmearn)\.com$/,
/^(oturl|glory-link|linkjust|best5link|clicksfly|bit-url)\.com$/,
/^(www\.)?3rabshort\.com$/,
/^(tokenfly|psl|clik|senada)\.pw$/,
/^(wicr|adbilty)\.me$/,
/^stfly\.press$/,
/^adshort\.co$/,
/^linkrex\.net$/,
/^wi\.cr$/,
/^geki\.tech$/,
/^clk\.ink$/,
/^cuturl\.in$/,
/^clk\.sh$/,
/^short\.pe$/,
/^ourl\.io$/,
/^urlcloud\.us$/,
],
path: /^\/st/,
query: /^\?api=(\w+)&url=(.+)/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(decodeURIComponent(m.query[2]));
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^(www\.)?spaste\.com$/,
path: /^\/r\//,
query: /^\?link=(.+)/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(m.query[1]);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^(\w+\.)?pixxxels\.org$/,
},
async start () {
const path = window.location.href.replace('\.org', '\.cc');
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: /^img\.yt$/,
},
async start () {
const path = window.location.href.replace('g\.yt', 'x\.to');
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(path);
},
});
_REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["_"].register({
rule: {
host: [
/^j\.gs$/,
/^ay\.gy$/,
],
path: /^\/\d+\/(.+)/,
},
async start (m) {
await _REDIREV_NAMESPACE___WEBPACK_IMPORTED_MODULE_0__["$"].openLink(m.path[1]);
},
});
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------//
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "_", function() { return _; });
__webpack_require__.d(__webpack_exports__, "$", function() { return $; });
var util_ajax__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
var util_cookie__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
var util_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
var util_dispatcher__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
var util_dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
var util_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(11);
var util_link__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(12);
var util_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(5);
var util_misc__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(13);
var util_platform__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3);
const _ = {
RedirevError: util_core__WEBPACK_IMPORTED_MODULE_2__["RedirevError"],
evil: util_misc__WEBPACK_IMPORTED_MODULE_8__["evil"],
find: util_core__WEBPACK_IMPORTED_MODULE_2__["find"],
forEach: util_core__WEBPACK_IMPORTED_MODULE_2__["forEach"],
generateRandomIP: util_misc__WEBPACK_IMPORTED_MODULE_8__["generateRandomIP"],
info: util_logger__WEBPACK_IMPORTED_MODULE_7__["info"],
none: util_core__WEBPACK_IMPORTED_MODULE_2__["none"],
partial: util_core__WEBPACK_IMPORTED_MODULE_2__["partial"],
register: util_dispatcher__WEBPACK_IMPORTED_MODULE_3__["register"],
tryEvery: util_core__WEBPACK_IMPORTED_MODULE_2__["tryEvery"],
wait: util_core__WEBPACK_IMPORTED_MODULE_2__["wait"],
warn: util_logger__WEBPACK_IMPORTED_MODULE_7__["warn"],
};
function $ (selector, context) {
return Object(util_dom__WEBPACK_IMPORTED_MODULE_4__["querySelector"])(selector, context);
}
$.$ = util_dom__WEBPACK_IMPORTED_MODULE_4__["querySelectorOrNull"];
$.$$ = util_dom__WEBPACK_IMPORTED_MODULE_4__["querySelectorAll"];
$.block = util_dom__WEBPACK_IMPORTED_MODULE_4__["block"];
$.get = util_ajax__WEBPACK_IMPORTED_MODULE_0__["get"];
$.getCookie = util_cookie__WEBPACK_IMPORTED_MODULE_1__["getCookie"];
$.nuke = util_misc__WEBPACK_IMPORTED_MODULE_8__["nuke"];
$.openImage = util_image__WEBPACK_IMPORTED_MODULE_5__["openImage"];
$.openLink = util_link__WEBPACK_IMPORTED_MODULE_6__["openLink"];
$.post = util_ajax__WEBPACK_IMPORTED_MODULE_0__["post"];
$.remove = util_dom__WEBPACK_IMPORTED_MODULE_4__["remove"];
$.removeAllTimer = util_misc__WEBPACK_IMPORTED_MODULE_8__["removeAllTimer"];
$.resetCookies = util_cookie__WEBPACK_IMPORTED_MODULE_1__["resetCookies"];
$.searchFromScripts = util_dom__WEBPACK_IMPORTED_MODULE_4__["searchFromScripts"];
$.setCookie = util_cookie__WEBPACK_IMPORTED_MODULE_1__["setCookie"];
$.toDOM = util_dom__WEBPACK_IMPORTED_MODULE_4__["toDOM"];
$.window = util_platform__WEBPACK_IMPORTED_MODULE_9__["usw"];
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "get", function() { return get; });
__webpack_require__.d(__webpack_exports__, "post", function() { return post; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
var util_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
var util_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
class AjaxError extends util_core__WEBPACK_IMPORTED_MODULE_0__["RedirevError"] {
constructor (method, url, data, headers, status, response) {
super(`${method} ${url} got ${status}`);
this._method = method;
this._url = url;
this._data = data;
this._headers = headers;
this._status = status;
this._response = response;
}
get name () {
return 'AjaxError';
}
get method () {
return this._method;
}
get url () {
return this._url;
}
get data () {
return this._data;
}
get headers () {
return this._headers;
}
get status () {
return this._status;
}
get response () {
return this._response;
}
}
function deepJoin (prefix, object) {
const keys = Object.getOwnPropertyNames(object);
const mapped = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["map"])(keys, (k) => {
const v = object[k];
const key = `${prefix}[${k}]`;
if (typeof v === 'object') {
return deepJoin(key, v);
}
const tmp = [key, v].map(encodeURIComponent);
return tmp.join('=');
});
return mapped.join('&');
}
function toQuery (data) {
const type = typeof data;
if (data === null || (type !== 'string' && type !== 'object')) {
return '';
}
if (type === 'string') {
return data;
}
if (data instanceof String) {
return data.toString();
}
const keys = Object.getOwnPropertyNames(data);
return Object(util_core__WEBPACK_IMPORTED_MODULE_0__["map"])(keys, (k) => {
const v = data[k];
if (typeof v === 'object') {
return deepJoin(k, v);
}
const tmp = [k, v].map(encodeURIComponent);
return tmp.join('=');
}).join('&');
}
function ajax (method, url, data, headers) {
Object(util_logger__WEBPACK_IMPORTED_MODULE_2__["debug"])('ajax', method, url, data, headers);
const l = document.createElement('a');
l.href = url;
const reqHost = l.hostname;
const overrideHeaders = {
Host: reqHost || window.location.host,
Origin: window.location.origin,
Referer: window.location.href,
'X-Requested-With': 'XMLHttpRequest',
};
Object(util_core__WEBPACK_IMPORTED_MODULE_0__["forEach"])(overrideHeaders, (v, k) => {
if (headers[k] === util_core__WEBPACK_IMPORTED_MODULE_0__["none"]) {
delete headers[k];
} else {
headers[k] = v;
}
});
if (data) {
if (headers['Content-Type'].indexOf('json') >= 0) {
data = JSON.stringify(data);
} else {
data = toQuery(data);
}
headers['Content-Length'] = data.length;
}
return new Promise((resolve, reject) => {
util_platform__WEBPACK_IMPORTED_MODULE_1__["GMAPI"].xmlHttpRequest({
method: method,
url: url,
data: data,
headers: headers,
onload (response) {
response = (typeof response.responseText !== 'undefined') ? response : this;
if (response.status !== 200) {
reject(new AjaxError(method, url, data, headers, response.status, response.responseText));
} else {
resolve(response.responseText);
}
},
onerror (response) {
response = (typeof response.responseText !== 'undefined') ? response : this;
reject(new AjaxError(method, url, data, headers, response.status, response.responseText));
},
});
});
}
function get (url, data, headers) {
data = toQuery(data);
data = data ? '?' + data : '';
headers = headers || {};
return ajax('GET', url + data, '', headers);
}
function post (url, data, headers) {
const h = {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
};
if (headers) {
Object(util_core__WEBPACK_IMPORTED_MODULE_0__["forEach"])(headers, (v, k) => {
h[k] = v;
});
}
return ajax('POST', url, data, h);
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "setCookie", function() { return setCookie; });
__webpack_require__.d(__webpack_exports__, "getCookie", function() { return getCookie; });
__webpack_require__.d(__webpack_exports__, "resetCookies", function() { return resetCookies; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
function setCookie (key, value) {
document.cookie = `${key}=${value};path=${location.pathname};`;
}
function getCookie (key) {
let [, c,] = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["find"])(document.cookie.split(';'), (v) => {
const k = v.replace(/^\s*([a-zA-Z0-9-_]+)=.+$/, '$1');
if (k !== key) {
return util_core__WEBPACK_IMPORTED_MODULE_0__["none"];
}
});
if (c === util_core__WEBPACK_IMPORTED_MODULE_0__["none"]) {
return null;
}
c = c.replace(/^\s*[a-zA-Z0-9-_]+=([^;]+).?$/, '$1');
if (!c) {
return null;
}
return c;
}
function resetCookies () {
const a = document.domain;
const b = document.domain.replace(/^www\./, '');
const c = document.domain.replace(/^(\w+\.)+?(\w+\.\w+)$/, '$2');
const d = (new Date(1e3)).toUTCString();
Object(util_core__WEBPACK_IMPORTED_MODULE_0__["forEach"])(document.cookie.split(';'), (v) => {
const k = v.replace(/^\s*(\w+)=.+$/, '$1');
document.cookie = `${k}=;expires=${d};`;
document.cookie = `${k}=;path=/;expires=${d};`;
const e = (a, b, c) => `${a}=;path=/;domain=${b};expires=${c};`;
document.cookie = e(k, a, d);
document.cookie = e(k, b, d);
document.cookie = e(k, c, d);
});
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "block", function() { return block; });
__webpack_require__.d(__webpack_exports__, "querySelector", function() { return querySelector; });
__webpack_require__.d(__webpack_exports__, "querySelectorAll", function() { return querySelectorAll; });
__webpack_require__.d(__webpack_exports__, "querySelectorOrNull", function() { return querySelectorOrNull; });
__webpack_require__.d(__webpack_exports__, "remove", function() { return remove; });
__webpack_require__.d(__webpack_exports__, "searchFromScripts", function() { return searchFromScripts; });
__webpack_require__.d(__webpack_exports__, "toDOM", function() { return toDOM; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
var util_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
class DomNotFoundError extends util_core__WEBPACK_IMPORTED_MODULE_0__["RedirevError"] {
constructor (selector) {
super(`\`${selector}\` not found`);
}
get name () {
return 'DomNotFoundError';
}
}
function querySelector (selector, context) {
if (!context || !context.querySelector) {
context = document;
}
const n = context.querySelector(selector);
if (!n) {
throw new DomNotFoundError(selector);
}
return n;
}
function querySelectorOrNull (selector, context) {
try {
return querySelector(selector, context);
} catch (e) {
return null;
}
}
function querySelectorAll (selector, context) {
if (!context || !context.querySelectorAll) {
context = document;
}
const ns = context.querySelectorAll(selector);
return ns;
}
function toDOM (rawHTML) {
try {
const parser = new DOMParser();
const DOMHTML = parser.parseFromString(rawHTML, 'text/html');
return DOMHTML;
} catch (e) {
throw new util_core__WEBPACK_IMPORTED_MODULE_0__["RedirevError"]('could not parse HTML to DOM');
}
}
function remove (selector, context) {
const nodes = querySelectorAll(selector, context);
Object(util_core__WEBPACK_IMPORTED_MODULE_0__["forEach"])(nodes, (e) => {
Object(util_logger__WEBPACK_IMPORTED_MODULE_1__["debug"])('removed', e);
e.remove();
});
}
function block (selector, context=null) {
if (!context) {
context = document;
}
let fn = null;
if (Object(util_core__WEBPACK_IMPORTED_MODULE_0__["isString"])(selector)) {
fn = () => {
remove(selector, context);
};
} else if (typeof selector === 'function') {
fn = (mutation) => {
mutation.addedNodes.forEach((node) => {
if (selector(node)) {
node.parentNode.removeChild(node);
}
});
};
} else {
throw new TypeError('wrong selector');
}
const o = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
fn(mutation);
});
});
o.observe(context, {
childList: true,
subtree: true,
});
}
function searchFromScriptsByRegExp (pattern, context) {
const scripts = querySelectorAll('script', context);
const [, , m] = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["find"])(scripts, (s) => {
const m = s.textContent.match(pattern);
if (!m) {
return util_core__WEBPACK_IMPORTED_MODULE_0__["none"];
}
return m;
});
if (m === util_core__WEBPACK_IMPORTED_MODULE_0__["none"]) {
return null;
}
return m;
}
function searchFromScriptsByString (pattern, context) {
const scripts = querySelectorAll('script', context);
const [, m,] = Object(util_core__WEBPACK_IMPORTED_MODULE_0__["find"])(scripts, (s) => {
const m = s.textContent.indexOf(pattern);
if (m < 0) {
return util_core__WEBPACK_IMPORTED_MODULE_0__["none"];
}
return m;
});
if (m === util_core__WEBPACK_IMPORTED_MODULE_0__["none"]) {
return null;
}
return m.textContent;
}
function searchFromScripts (pattern, context) {
if (pattern instanceof RegExp) {
return searchFromScriptsByRegExp(pattern, context);
} else if (Object(util_core__WEBPACK_IMPORTED_MODULE_0__["isString"])(pattern)) {
return searchFromScriptsByString(pattern, context);
} else {
return null;
}
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "openImage", function() { return openImage; });
var util_link__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
var util_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
var util_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
var util_misc__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(13);
var util_platform__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3);
async function openImage (imgSrc, options) {
options = options || {};
const replace = !!options.replace;
const referer = !!options.referer;
if (replace) {
await replaceBody(imgSrc);
return;
}
const redirectImage = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getValue('redirect_image');
if (redirectImage) {
await Object(util_link__WEBPACK_IMPORTED_MODULE_0__["openLink"])(imgSrc, {
referer: referer,
});
}
}
function enableScrolling () {
const o = document.compatMode === 'CSS1Compat' ? document.documentElement : document.body;
o.style.overflow = '';
}
function toggleShrinking () {
this.classList.toggle('redirev-shrinked');
}
function checkScaling () {
const nw = this.naturalWidth;
const nh = this.naturalHeight;
const cw = document.documentElement.clientWidth;
const ch = document.documentElement.clientHeight;
if ((nw > cw || nh > ch) && !this.classList.contains('redirev-resizable')) {
this.classList.add('redirev-resizable');
this.classList.add('redirev-shrinked');
this.addEventListener('click', toggleShrinking);
} else {
this.removeEventListener('click', toggleShrinking);
this.classList.remove('redirev-shrinked');
this.classList.remove('redirev-resizable');
}
}
async function scaleImage (i) {
const siURL = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getResourceUrl('scaleImage');
appendStyleURL(siURL);
if (i.naturalWidth && i.naturalHeight) {
checkScaling.call(i);
} else {
i.addEventListener('load', checkScaling);
}
let h = 0;
window.addEventListener('resize', () => {
window.clearTimeout(h);
h = window.setTimeout(checkScaling.bind(i), 100);
});
}
async function changeBackground () {
const bgImage = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getResourceUrl('bgImage');
document.body.style.backgroundColor = '#222222';
document.body.style.backgroundImage = `url('${bgImage}')`;
}
async function alignCenter () {
const acURL = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getResourceUrl('alignCenter');
appendStyleURL(acURL);
}
function injectStyle (d, i) {
Object(util_dom__WEBPACK_IMPORTED_MODULE_1__["remove"])('style, link[rel=stylesheet]');
d.id = 'redirev-wrapper';
i.id = 'redirev-image';
}
function appendStyleURL (url) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url;
document.head.appendChild(link);
}
async function replaceBody (imgSrc) {
const redirectImage = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getValue('redirect_image');
if (!redirectImage) {
return;
}
if (!imgSrc) {
Object(util_logger__WEBPACK_IMPORTED_MODULE_2__["warn"])('false url');
return;
}
Object(util_logger__WEBPACK_IMPORTED_MODULE_2__["info"])(`replacing body with \`${imgSrc}\` ...`);
Object(util_misc__WEBPACK_IMPORTED_MODULE_3__["removeAllTimer"])();
enableScrolling();
document.body = document.createElement('body');
const d = document.createElement('div');
document.body.appendChild(d);
const i = document.createElement('img');
i.src = imgSrc;
d.appendChild(i);
const ac = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getValue('align_center');
const si = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getValue('scale_image');
if (ac || si) {
injectStyle(d, i);
}
if (ac) {
await alignCenter();
}
const cb = await util_platform__WEBPACK_IMPORTED_MODULE_4__["GMAPI"].getValue('change_background');
if (cb) {
await changeBackground();
}
if (si) {
await scaleImage(i);
}
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "openLink", function() { return openLink; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
var util_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
function prepare (e) {
if (!document.body) {
document.body = document.createElement('body');
}
document.body.appendChild(e);
return Object(util_core__WEBPACK_IMPORTED_MODULE_0__["wait"])(0);
}
async function get (url) {
const a = document.createElement('a');
a.href = url;
let clicked = false;
a.addEventListener('click', (event) => {
event.stopPropagation();
clicked = true;
}, true);
await prepare(a);
a.click();
const tick = setInterval(() => {
if (clicked) {
Object(util_logger__WEBPACK_IMPORTED_MODULE_1__["info"])('already clicked');
clearInterval(tick);
return;
}
Object(util_logger__WEBPACK_IMPORTED_MODULE_1__["info"])('try again');
a.click();
}, 500);
}
async function post (path, params) {
params = params || {};
const form = document.createElement('form');
form.method = 'post';
form.action = path;
Object(util_core__WEBPACK_IMPORTED_MODULE_0__["forEach"])(params, (value, key) => {
const input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.value = value;
form.appendChild(input);
});
await prepare(form);
form.submit();
}
async function openLink (to, options) {
if (!Object(util_core__WEBPACK_IMPORTED_MODULE_0__["isString"])(to) && !to) {
Object(util_logger__WEBPACK_IMPORTED_MODULE_1__["warn"])('false URL');
return;
}
options = options || {};
const withReferer = typeof options.referer === 'undefined' ? true : options.referer;
const postData = options.post;
const from = window.location.toString();
Object(util_logger__WEBPACK_IMPORTED_MODULE_1__["info"])(`${from} -> ${to}`);
if (postData) {
await post(to, postData);
return;
}
if (withReferer) {
await get(to);
return;
}
window.top.location.replace(to);
}
}),
(function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, "removeAllTimer", function() { return removeAllTimer; });
__webpack_require__.d(__webpack_exports__, "nuke", function() { return nuke; });
__webpack_require__.d(__webpack_exports__, "generateRandomIP", function() { return generateRandomIP; });
__webpack_require__.d(__webpack_exports__, "evil", function() { return evil; });
var util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
var util_platform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
var util_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
function removeAllTimer () {
let handle = window.setInterval(util_core__WEBPACK_IMPORTED_MODULE_0__["nop"], 10);
while (handle > 0) {
window.clearInterval(handle--);
}
handle = window.setTimeout(util_core__WEBPACK_IMPORTED_MODULE_0__["nop"], 10);
while (handle > 0) {
window.clearTimeout(handle--);
}
}
function nuke (url) {
try {
util_platform__WEBPACK_IMPORTED_MODULE_1__["usw"].document.write('nuked by Redirev, leading to ...<br/>');
} catch (e) {
Object(util_logger__WEBPACK_IMPORTED_MODULE_2__["warn"])('nuke failed', e);
}
const a = document.createElement('a');
a.href = url;
a.textContent = url;
document.body.appendChild(a);
}
function generateRandomIP () {
return [0, 0, 0, 0].map(() => {
return Math.floor(Math.random() * 256);
}).join('.');
}
function evil (script) {
return ((
GM,
GM_deleteValue,
GM_getResourceURL,
GM_getValue,
GM_openInTab,
GM_registerMenuCommand,
GM_setValue,
GM_xmlhttpRequest,
unsafeWindow,
window,
) => {
return eval(script);
})();
}
})
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment