Automatically sort teaser images on /videos, /images, /subscriptions, /users, /playlist, and sidebars using customizable sort function. Can load and sort multiple pages at once.
当前为
// ==UserScript== // @name Iwara Custom Sort // @version 1.0.0 // @description Automatically sort teaser images on /videos, /images, /subscriptions, /users, /playlist, and sidebars using customizable sort function. Can load and sort multiple pages at once. // @match http://ecchi.iwara.tv/* // @match https://ecchi.iwara.tv/* // @match http://www.iwara.tv/* // @match https://www.iwara.tv/* // @name:ja Iwara Custom ソート // @run-at document-end // @grant GM.setValue // @grant GM.getValue // @grant GM.deleteValue // @grant GM.listValues // @license AGPL-3.0-or-later // @description:ja /videos、/images、/subscriptions、/users、/playlistとサイドバーのサムネイルを自動的にソートします。ソート方法はカスタマイズすることができます、一度に複数のページを読み込んでソートすることができます。 // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js#sha384-TFtJUtY6yVJyCjuXjw0Jiqz5NN/VKgIP0kl8s5revINrTJQwHD0CtZWcnrrOapjY // @require https://unpkg.com/[email protected]/dist/loglevel.min.js#sha384-7gGuWfek8Ql6j/uNDFrS0BCe4x2ZihD4B68w9Eu580OVHJBV+bl3rZmEWC7q5/Gj // @require https://unpkg.com/[email protected]/bundles/rxjs.umd.min.js#sha384-+VJt6dSQYKxS5YwAGX+zSPDqOcLAUx2tCjV8jSWnyJH8hWTgrHSZAt1106u1VmLn // @require https://unpkg.com/[email protected]/mithril.min.js#sha384-vo9crXih40MlEv6JWHqS7SsPiFp+76csaWQFOF2UU0/xI58Jm/ZvK/1UtpaicJT9 // @namespace https://greasyfork.org/users/245195 // ==/UserScript== /* jshint esversion: 6 */ (function(modules) { // webpackBootstrap // The module cache var installedModules = {}; // The require function function __webpack_require__(moduleId) { // Check if module is in cache if(installedModules[moduleId]) { return installedModules[moduleId].exports; } // Create a new module (and put it into the cache) var module = installedModules[moduleId] = { i: moduleId, l: false, exports: {} }; // Execute the module function modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); // Flag the module as loaded module.l = true; // Return the exports of the module return module.exports; } // expose the modules object (__webpack_modules__) __webpack_require__.m = modules; // expose the module cache __webpack_require__.c = installedModules; // define getter function for harmony exports __webpack_require__.d = function(exports, name, getter) { if(!__webpack_require__.o(exports, name)) { Object.defineProperty(exports, name, { enumerable: true, get: getter }); } }; // define __esModule on exports __webpack_require__.r = function(exports) { if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); } Object.defineProperty(exports, '__esModule', { value: true }); }; // create a fake namespace object // mode & 1: value is a module id, require it // mode & 2: merge all properties of value into the ns // mode & 4: return value when already ns object // mode & 8|1: behave like require __webpack_require__.t = function(value, mode) { if(mode & 1) value = __webpack_require__(value); if(mode & 8) return value; if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; var ns = Object.create(null); __webpack_require__.r(ns); Object.defineProperty(ns, 'default', { enumerable: true, value: value }); if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); return ns; }; // getDefaultExport function for compatibility with non-harmony modules __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; }; // Object.prototype.hasOwnProperty.call __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; // __webpack_public_path__ __webpack_require__.p = ""; // Load entry module and return exports return __webpack_require__(__webpack_require__.s = 14); }) ([ (function(module, exports) { module.exports = rxjs.operators; }), (function(module, exports) { module.exports = rxjs; }), (function(module, exports) { module.exports = m; }), (function(module, exports) { module.exports = log; }), (function(module, exports, __webpack_require__) { "use strict"; (function(global) { var objectAssign = __webpack_require__(9); function compare(a, b) { if (a === b) { return 0; } var x = a.length; var y = b.length; for (var i = 0, len = Math.min(x, y); i < len; ++i) { if (a[i] !== b[i]) { x = a[i]; y = b[i]; break; } } if (x < y) { return -1; } if (y < x) { return 1; } return 0; } function isBuffer(b) { if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { return global.Buffer.isBuffer(b); } return !!(b != null && b._isBuffer); } var util = __webpack_require__(10); var hasOwn = Object.prototype.hasOwnProperty; var pSlice = Array.prototype.slice; var functionsHaveNames = (function () { return function foo() {}.name === 'foo'; }()); function pToString (obj) { return Object.prototype.toString.call(obj); } function isView(arrbuf) { if (isBuffer(arrbuf)) { return false; } if (typeof global.ArrayBuffer !== 'function') { return false; } if (typeof ArrayBuffer.isView === 'function') { return ArrayBuffer.isView(arrbuf); } if (!arrbuf) { return false; } if (arrbuf instanceof DataView) { return true; } if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { return true; } return false; } var assert = module.exports = ok; var regex = /\s*function\s+([^\(\s]*)\s*/; function getName(func) { if (!util.isFunction(func)) { return; } if (functionsHaveNames) { return func.name; } var str = func.toString(); var match = str.match(regex); return match && match[1]; } assert.AssertionError = function AssertionError(options) { this.name = 'AssertionError'; this.actual = options.actual; this.expected = options.expected; this.operator = options.operator; if (options.message) { this.message = options.message; this.generatedMessage = false; } else { this.message = getMessage(this); this.generatedMessage = true; } var stackStartFunction = options.stackStartFunction || fail; if (Error.captureStackTrace) { Error.captureStackTrace(this, stackStartFunction); } else { var err = new Error(); if (err.stack) { var out = err.stack; var fn_name = getName(stackStartFunction); var idx = out.indexOf('\n' + fn_name); if (idx >= 0) { var next_line = out.indexOf('\n', idx + 1); out = out.substring(next_line + 1); } this.stack = out; } } }; util.inherits(assert.AssertionError, Error); function truncate(s, n) { if (typeof s === 'string') { return s.length < n ? s : s.slice(0, n); } else { return s; } } function inspect(something) { if (functionsHaveNames || !util.isFunction(something)) { return util.inspect(something); } var rawname = getName(something); var name = rawname ? ': ' + rawname : ''; return '[Function' + name + ']'; } function getMessage(self) { return truncate(inspect(self.actual), 128) + ' ' + self.operator + ' ' + truncate(inspect(self.expected), 128); } function fail(actual, expected, message, operator, stackStartFunction) { throw new assert.AssertionError({ message: message, actual: actual, expected: expected, operator: operator, stackStartFunction: stackStartFunction }); } assert.fail = fail; function ok(value, message) { if (!value) fail(value, true, message, '==', assert.ok); } assert.ok = ok; assert.equal = function equal(actual, expected, message) { if (actual != expected) fail(actual, expected, message, '==', assert.equal); }; assert.notEqual = function notEqual(actual, expected, message) { if (actual == expected) { fail(actual, expected, message, '!=', assert.notEqual); } }; assert.deepEqual = function deepEqual(actual, expected, message) { if (!_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'deepEqual', assert.deepEqual); } }; assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { if (!_deepEqual(actual, expected, true)) { fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); } }; function _deepEqual(actual, expected, strict, memos) { if (actual === expected) { return true; } else if (isBuffer(actual) && isBuffer(expected)) { return compare(actual, expected) === 0; } else if (util.isDate(actual) && util.isDate(expected)) { return actual.getTime() === expected.getTime(); } else if (util.isRegExp(actual) && util.isRegExp(expected)) { return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase; } else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) { return strict ? actual === expected : actual == expected; } else if (isView(actual) && isView(expected) && pToString(actual) === pToString(expected) && !(actual instanceof Float32Array || actual instanceof Float64Array)) { return compare(new Uint8Array(actual.buffer), new Uint8Array(expected.buffer)) === 0; } else if (isBuffer(actual) !== isBuffer(expected)) { return false; } else { memos = memos || {actual: [], expected: []}; var actualIndex = memos.actual.indexOf(actual); if (actualIndex !== -1) { if (actualIndex === memos.expected.indexOf(expected)) { return true; } } memos.actual.push(actual); memos.expected.push(expected); return objEquiv(actual, expected, strict, memos); } } function isArguments(object) { return Object.prototype.toString.call(object) == '[object Arguments]'; } function objEquiv(a, b, strict, actualVisitedObjects) { if (a === null || a === undefined || b === null || b === undefined) return false; if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b; if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false; var aIsArgs = isArguments(a); var bIsArgs = isArguments(b); if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) return false; if (aIsArgs) { a = pSlice.call(a); b = pSlice.call(b); return _deepEqual(a, b, strict); } var ka = objectKeys(a); var kb = objectKeys(b); var key, i; if (ka.length !== kb.length) return false; ka.sort(); kb.sort(); for (i = ka.length - 1; i >= 0; i--) { if (ka[i] !== kb[i]) return false; } for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) return false; } return true; } assert.notDeepEqual = function notDeepEqual(actual, expected, message) { if (_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); } }; assert.notDeepStrictEqual = notDeepStrictEqual; function notDeepStrictEqual(actual, expected, message) { if (_deepEqual(actual, expected, true)) { fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); } } assert.strictEqual = function strictEqual(actual, expected, message) { if (actual !== expected) { fail(actual, expected, message, '===', assert.strictEqual); } }; assert.notStrictEqual = function notStrictEqual(actual, expected, message) { if (actual === expected) { fail(actual, expected, message, '!==', assert.notStrictEqual); } }; function expectedException(actual, expected) { if (!actual || !expected) { return false; } if (Object.prototype.toString.call(expected) == '[object RegExp]') { return expected.test(actual); } try { if (actual instanceof expected) { return true; } } catch (e) { } if (Error.isPrototypeOf(expected)) { return false; } return expected.call({}, actual) === true; } function _tryBlock(block) { var error; try { block(); } catch (e) { error = e; } return error; } function _throws(shouldThrow, block, expected, message) { var actual; if (typeof block !== 'function') { throw new TypeError('"block" argument must be a function'); } if (typeof expected === 'string') { message = expected; expected = null; } actual = _tryBlock(block); message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.'); if (shouldThrow && !actual) { fail(actual, expected, 'Missing expected exception' + message); } var userProvidedMessage = typeof message === 'string'; var isUnwantedException = !shouldThrow && util.isError(actual); var isUnexpectedException = !shouldThrow && actual && !expected; if ((isUnwantedException && userProvidedMessage && expectedException(actual, expected)) || isUnexpectedException) { fail(actual, expected, 'Got unwanted exception' + message); } if ((shouldThrow && actual && expected && !expectedException(actual, expected)) || (!shouldThrow && actual)) { throw actual; } } assert.throws = function(block, message) { _throws(true, block, error, message); }; assert.doesNotThrow = function(block, message) { _throws(false, block, error, message); }; assert.ifError = function(err) { if (err) throw err; }; function strict(value, message) { if (!value) fail(value, true, message, '==', strict); } assert.strict = objectAssign(strict, assert, { equal: assert.strictEqual, deepEqual: assert.deepStrictEqual, notEqual: assert.notStrictEqual, notDeepEqual: assert.notDeepStrictEqual }); assert.strict.strict = assert.strict; var objectKeys = Object.keys || function (obj) { var keys = []; for (var key in obj) { if (hasOwn.call(obj, key)) keys.push(key); } return keys; }; }.call(this, __webpack_require__(8))) }), (function(module, exports, __webpack_require__) { "use strict"; const randomInteger = (minimum, maximum) => Math.floor((Math.random() * (maximum - minimum + 1)) + minimum); const createAbortError = () => { const error = new Error('Delay aborted'); error.name = 'AbortError'; return error; }; const createDelay = ({clearTimeout: defaultClear, setTimeout: set, willResolve}) => (ms, {value, signal} = {}) => { if (signal && signal.aborted) { return Promise.reject(createAbortError()); } let timeoutId; let settle; let rejectFn; const clear = defaultClear || clearTimeout; const signalListener = () => { clear(timeoutId); rejectFn(createAbortError()); }; const cleanup = () => { if (signal) { signal.removeEventListener('abort', signalListener); } }; const delayPromise = new Promise((resolve, reject) => { settle = () => { cleanup(); if (willResolve) { resolve(value); } else { reject(value); } }; rejectFn = reject; timeoutId = (set || setTimeout)(settle, ms); }); if (signal) { signal.addEventListener('abort', signalListener, {once: true}); } delayPromise.clear = () => { clear(timeoutId); timeoutId = null; settle(); }; return delayPromise; }; const delay = createDelay({willResolve: true}); delay.reject = createDelay({willResolve: false}); delay.range = (minimum, maximum, options) => delay(randomInteger(minimum, maximum), options); delay.createWithTimers = ({clearTimeout, setTimeout}) => { const delay = createDelay({clearTimeout, setTimeout, willResolve: true}); delay.reject = createDelay({clearTimeout, setTimeout, willResolve: false}); return delay; }; module.exports = delay; module.exports.default = delay; }), (function(module, exports) { module.exports = Swal; }), (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bindTo_ = exports.bind_ = exports.hole = exports.pipe = exports.untupled = exports.tupled = exports.absurd = exports.decrement = exports.increment = exports.tuple = exports.flow = exports.flip = exports.constVoid = exports.constUndefined = exports.constNull = exports.constFalse = exports.constTrue = exports.constant = exports.not = exports.unsafeCoerce = exports.identity = void 0; function identity(a) { return a; } exports.identity = identity; exports.unsafeCoerce = identity; function not(predicate) { return function (a) { return !predicate(a); }; } exports.not = not; function constant(a) { return function () { return a; }; } exports.constant = constant; exports.constTrue = function () { return true; }; exports.constFalse = function () { return false; }; exports.constNull = function () { return null; }; exports.constUndefined = function () { return; }; exports.constVoid = function () { return; }; function flip(f) { return function (b, a) { return f(a, b); }; } exports.flip = flip; function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { switch (arguments.length) { case 1: return ab; case 2: return function () { return bc(ab.apply(this, arguments)); }; case 3: return function () { return cd(bc(ab.apply(this, arguments))); }; case 4: return function () { return de(cd(bc(ab.apply(this, arguments)))); }; case 5: return function () { return ef(de(cd(bc(ab.apply(this, arguments))))); }; case 6: return function () { return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); }; case 7: return function () { return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); }; case 8: return function () { return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); }; case 9: return function () { return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); }; } return; } exports.flow = flow; function tuple() { var t = []; for (var _i = 0; _i < arguments.length; _i++) { t[_i] = arguments[_i]; } return t; } exports.tuple = tuple; function increment(n) { return n + 1; } exports.increment = increment; function decrement(n) { return n - 1; } exports.decrement = decrement; function absurd(_) { throw new Error('Called `absurd` function which should be uncallable'); } exports.absurd = absurd; function tupled(f) { return function (a) { return f.apply(void 0, a); }; } exports.tupled = tupled; function untupled(f) { return function () { var a = []; for (var _i = 0; _i < arguments.length; _i++) { a[_i] = arguments[_i]; } return f(a); }; } exports.untupled = untupled; function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) { switch (arguments.length) { case 1: return a; case 2: return ab(a); case 3: return bc(ab(a)); case 4: return cd(bc(ab(a))); case 5: return de(cd(bc(ab(a)))); case 6: return ef(de(cd(bc(ab(a))))); case 7: return fg(ef(de(cd(bc(ab(a)))))); case 8: return gh(fg(ef(de(cd(bc(ab(a))))))); case 9: return hi(gh(fg(ef(de(cd(bc(ab(a)))))))); case 10: return ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))); case 11: return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))); case 12: return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))); case 13: return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))); case 14: return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))); case 15: return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))); case 16: return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))); case 17: return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))); case 18: return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))); case 19: return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))); case 20: return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))))); } return; } exports.pipe = pipe; exports.hole = absurd; exports.bind_ = function (a, name, b) { var _a; return Object.assign({}, a, (_a = {}, _a[name] = b, _a)); }; exports.bindTo_ = function (name) { return function (b) { var _a; return (_a = {}, _a[name] = b, _a); }; }; }), (function(module, exports) { var g; g = (function() { return this; })(); try { g = g || new Function("return this")(); } catch (e) { if (typeof window === "object") g = window; } module.exports = g; }), (function(module, exports, __webpack_require__) { "use strict"; var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function shouldUseNative() { try { if (!Object.assign) { return false; } var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; } var test2 = {}; for (var i = 0; i < 10; i++) { test2['_' + String.fromCharCode(i)] = i; } var order2 = Object.getOwnPropertyNames(test2).map(function (n) { return test2[n]; }); if (order2.join('') !== '0123456789') { return false; } var test3 = {}; 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { test3[letter] = letter; }); if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') { return false; } return true; } catch (err) { return false; } } module.exports = shouldUseNative() ? Object.assign : function (target, source) { var from; var to = toObject(target); var symbols; for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; } } } } return to; }; }), (function(module, exports, __webpack_require__) { (function(process) {// Copyright Joyent, Inc. and other Node contributors. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) { var keys = Object.keys(obj); var descriptors = {}; for (var i = 0; i < keys.length; i++) { descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]); } return descriptors; }; var formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (!isString(f)) { var objects = []; for (var i = 0; i < arguments.length; i++) { objects.push(inspect(arguments[i])); } return objects.join(' '); } var i = 1; var args = arguments; var len = args.length; var str = String(f).replace(formatRegExp, function(x) { if (x === '%%') return '%'; if (i >= len) return x; switch (x) { case '%s': return String(args[i++]); case '%d': return Number(args[i++]); case '%j': try { return JSON.stringify(args[i++]); } catch (_) { return '[Circular]'; } default: return x; } }); for (var x = args[i]; i < len; x = args[++i]) { if (isNull(x) || !isObject(x)) { str += ' ' + x; } else { str += ' ' + inspect(x); } } return str; }; exports.deprecate = function(fn, msg) { if (typeof process !== 'undefined' && process.noDeprecation === true) { return fn; } if (typeof process === 'undefined') { return function() { return exports.deprecate(fn, msg).apply(this, arguments); }; } var warned = false; function deprecated() { if (!warned) { if (process.throwDeprecation) { throw new Error(msg); } else if (process.traceDeprecation) { console.trace(msg); } else { console.error(msg); } warned = true; } return fn.apply(this, arguments); } return deprecated; }; var debugs = {}; var debugEnviron; exports.debuglog = function(set) { if (isUndefined(debugEnviron)) debugEnviron = process.env.NODE_DEBUG || ''; set = set.toUpperCase(); if (!debugs[set]) { if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { var pid = process.pid; debugs[set] = function() { var msg = exports.format.apply(exports, arguments); console.error('%s %d: %s', set, pid, msg); }; } else { debugs[set] = function() {}; } } return debugs[set]; }; function inspect(obj, opts) { var ctx = { seen: [], stylize: stylizeNoColor }; if (arguments.length >= 3) ctx.depth = arguments[2]; if (arguments.length >= 4) ctx.colors = arguments[3]; if (isBoolean(opts)) { ctx.showHidden = opts; } else if (opts) { exports._extend(ctx, opts); } if (isUndefined(ctx.showHidden)) ctx.showHidden = false; if (isUndefined(ctx.depth)) ctx.depth = 2; if (isUndefined(ctx.colors)) ctx.colors = false; if (isUndefined(ctx.customInspect)) ctx.customInspect = true; if (ctx.colors) ctx.stylize = stylizeWithColor; return formatValue(ctx, obj, ctx.depth); } exports.inspect = inspect; inspect.colors = { 'bold' : [1, 22], 'italic' : [3, 23], 'underline' : [4, 24], 'inverse' : [7, 27], 'white' : [37, 39], 'grey' : [90, 39], 'black' : [30, 39], 'blue' : [34, 39], 'cyan' : [36, 39], 'green' : [32, 39], 'magenta' : [35, 39], 'red' : [31, 39], 'yellow' : [33, 39] }; inspect.styles = { 'special': 'cyan', 'number': 'yellow', 'boolean': 'yellow', 'undefined': 'grey', 'null': 'bold', 'string': 'green', 'date': 'magenta', 'regexp': 'red' }; function stylizeWithColor(str, styleType) { var style = inspect.styles[styleType]; if (style) { return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm'; } else { return str; } } function stylizeNoColor(str, styleType) { return str; } function arrayToHash(array) { var hash = {}; array.forEach(function(val, idx) { hash[val] = true; }); return hash; } function formatValue(ctx, value, recurseTimes) { if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== exports.inspect && !(value.constructor && value.constructor.prototype === value)) { var ret = value.inspect(recurseTimes, ctx); if (!isString(ret)) { ret = formatValue(ctx, ret, recurseTimes); } return ret; } var primitive = formatPrimitive(ctx, value); if (primitive) { return primitive; } var keys = Object.keys(value); var visibleKeys = arrayToHash(keys); if (ctx.showHidden) { keys = Object.getOwnPropertyNames(value); } if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { return formatError(value); } if (keys.length === 0) { if (isFunction(value)) { var name = value.name ? ': ' + value.name : ''; return ctx.stylize('[Function' + name + ']', 'special'); } if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } if (isDate(value)) { return ctx.stylize(Date.prototype.toString.call(value), 'date'); } if (isError(value)) { return formatError(value); } } var base = '', array = false, braces = ['{', '}']; if (isArray(value)) { array = true; braces = ['[', ']']; } if (isFunction(value)) { var n = value.name ? ': ' + value.name : ''; base = ' [Function' + n + ']'; } if (isRegExp(value)) { base = ' ' + RegExp.prototype.toString.call(value); } if (isDate(value)) { base = ' ' + Date.prototype.toUTCString.call(value); } if (isError(value)) { base = ' ' + formatError(value); } if (keys.length === 0 && (!array || value.length == 0)) { return braces[0] + base + braces[1]; } if (recurseTimes < 0) { if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } else { return ctx.stylize('[Object]', 'special'); } } ctx.seen.push(value); var output; if (array) { output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); } else { output = keys.map(function(key) { return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); }); } ctx.seen.pop(); return reduceToSingleString(output, base, braces); } function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); if (isString(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') .replace(/'/g, "\\'") .replace(/\\"/g, '"') + '\''; return ctx.stylize(simple, 'string'); } if (isNumber(value)) return ctx.stylize('' + value, 'number'); if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); if (isNull(value)) return ctx.stylize('null', 'null'); } function formatError(value) { return '[' + Error.prototype.toString.call(value) + ']'; } function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { var output = []; for (var i = 0, l = value.length; i < l; ++i) { if (hasOwnProperty(value, String(i))) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true)); } else { output.push(''); } } keys.forEach(function(key) { if (!key.match(/^\d+$/)) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true)); } }); return output; } function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { var name, str, desc; desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; if (desc.get) { if (desc.set) { str = ctx.stylize('[Getter/Setter]', 'special'); } else { str = ctx.stylize('[Getter]', 'special'); } } else { if (desc.set) { str = ctx.stylize('[Setter]', 'special'); } } if (!hasOwnProperty(visibleKeys, key)) { name = '[' + key + ']'; } if (!str) { if (ctx.seen.indexOf(desc.value) < 0) { if (isNull(recurseTimes)) { str = formatValue(ctx, desc.value, null); } else { str = formatValue(ctx, desc.value, recurseTimes - 1); } if (str.indexOf('\n') > -1) { if (array) { str = str.split('\n').map(function(line) { return ' ' + line; }).join('\n').substr(2); } else { str = '\n' + str.split('\n').map(function(line) { return ' ' + line; }).join('\n'); } } } else { str = ctx.stylize('[Circular]', 'special'); } } if (isUndefined(name)) { if (array && key.match(/^\d+$/)) { return str; } name = JSON.stringify('' + key); if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { name = name.substr(1, name.length - 2); name = ctx.stylize(name, 'name'); } else { name = name.replace(/'/g, "\\'") .replace(/\\"/g, '"') .replace(/(^"|"$)/g, "'"); name = ctx.stylize(name, 'string'); } } return name + ': ' + str; } function reduceToSingleString(output, base, braces) { var numLinesEst = 0; var length = output.reduce(function(prev, cur) { numLinesEst++; if (cur.indexOf('\n') >= 0) numLinesEst++; return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; }, 0); if (length > 60) { return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1]; } return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; } function isArray(ar) { return Array.isArray(ar); } exports.isArray = isArray; function isBoolean(arg) { return typeof arg === 'boolean'; } exports.isBoolean = isBoolean; function isNull(arg) { return arg === null; } exports.isNull = isNull; function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; function isSymbol(arg) { return typeof arg === 'symbol'; } exports.isSymbol = isSymbol; function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; function isRegExp(re) { return isObject(re) && objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; function isDate(d) { return isObject(d) && objectToString(d) === '[object Date]'; } exports.isDate = isDate; function isError(e) { return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error); } exports.isError = isError; function isFunction(arg) { return typeof arg === 'function'; } exports.isFunction = isFunction; function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol typeof arg === 'undefined'; } exports.isPrimitive = isPrimitive; exports.isBuffer = __webpack_require__(12); function objectToString(o) { return Object.prototype.toString.call(o); } function pad(n) { return n < 10 ? '0' + n.toString(10) : n.toString(10); } var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; function timestamp() { var d = new Date(); var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); } exports.log = function() { console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); }; exports.inherits = __webpack_require__(13); exports._extend = function(origin, add) { if (!add || !isObject(add)) return origin; var keys = Object.keys(add); var i = keys.length; while (i--) { origin[keys[i]] = add[keys[i]]; } return origin; }; function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined; exports.promisify = function promisify(original) { if (typeof original !== 'function') throw new TypeError('The "original" argument must be of type Function'); if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { var fn = original[kCustomPromisifiedSymbol]; if (typeof fn !== 'function') { throw new TypeError('The "util.promisify.custom" argument must be of type Function'); } Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true }); return fn; } function fn() { var promiseResolve, promiseReject; var promise = new Promise(function (resolve, reject) { promiseResolve = resolve; promiseReject = reject; }); var args = []; for (var i = 0; i < arguments.length; i++) { args.push(arguments[i]); } args.push(function (err, value) { if (err) { promiseReject(err); } else { promiseResolve(value); } }); try { original.apply(this, args); } catch (err) { promiseReject(err); } return promise; } Object.setPrototypeOf(fn, Object.getPrototypeOf(original)); if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true }); return Object.defineProperties( fn, getOwnPropertyDescriptors(original) ); } exports.promisify.custom = kCustomPromisifiedSymbol function callbackifyOnRejected(reason, cb) { if (!reason) { var newReason = new Error('Promise was rejected with a falsy value'); newReason.reason = reason; reason = newReason; } return cb(reason); } function callbackify(original) { if (typeof original !== 'function') { throw new TypeError('The "original" argument must be of type Function'); } function callbackified() { var args = []; for (var i = 0; i < arguments.length; i++) { args.push(arguments[i]); } var maybeCb = args.pop(); if (typeof maybeCb !== 'function') { throw new TypeError('The last argument must be of type Function'); } var self = this; var cb = function() { return maybeCb.apply(self, arguments); }; original.apply(this, args) .then(function(ret) { process.nextTick(cb, null, ret) }, function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) }); } Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)); Object.defineProperties(callbackified, getOwnPropertyDescriptors(original)); return callbackified; } exports.callbackify = callbackify; }.call(this, __webpack_require__(11))) }), (function(module, exports) { var process = module.exports = {}; var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { return setTimeout(fun, 0); } if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { return cachedSetTimeout(fun, 0); } catch(e){ try { return cachedSetTimeout.call(null, fun, 0); } catch(e){ return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { return clearTimeout(marker); } if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { return cachedClearTimeout(marker); } catch (e){ try { return cachedClearTimeout.call(null, marker); } catch (e){ return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; }), (function(module, exports) { module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } }), (function(module, exports) { if (typeof Object.create === 'function') { module.exports = function inherits(ctor, superCtor) { ctor.super_ = superCtor ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } }); }; } else { module.exports = function inherits(ctor, superCtor) { ctor.super_ = superCtor var TempCtor = function () {} TempCtor.prototype = superCtor.prototype ctor.prototype = new TempCtor() ctor.prototype.constructor = ctor } } }), (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); var external_log_ = __webpack_require__(3); var delay = __webpack_require__(5); var delay_default = __webpack_require__.n(delay); var teaserElementSelector = ('.node-teaser, .node-sidebar_teaser, .node-wide_teaser'); var getTeaserContainers = ((node) => { const containerSelector = '.views-responsive-grid, .node-playlist' + ' .field-name-field-videos'; return Array.from(node.querySelectorAll(containerSelector)) .filter((grid) => grid.querySelector(teaserElementSelector)); }); var scriptChannelName = ('iwara custom sort'); var initChild = (async () => { const teaserContainers = getTeaserContainers(document); const channel = new BroadcastChannel(scriptChannelName); const hasTeasers = teaserContainers.length > 0; const message = { url: window.location.href, hasTeasers, }; if (hasTeasers) { await delay_default()(500); const addContainersToParents = (children, parents) => { for (let i = 0, j = 0; i < parents.length && j < children.length; i += 1) { const parent = parents[i]; const child = children[j]; if (parent.className === child.className) { child.className = ''; parent.append(child); j += 1; } } }; addContainersToParents(teaserContainers, getTeaserContainers(window.parent.document)); } channel.postMessage(message); }); var external_m_ = __webpack_require__(2); var external_m_default = __webpack_require__.n(external_m_); var external_rxjs_ = __webpack_require__(1); var external_rxjs_operators_ = __webpack_require__(0); var external_Swal_ = __webpack_require__(6); var external_Swal_default = __webpack_require__.n(external_Swal_); var classAttr = ((classNames) => (classNames.map((x) => `.${x}`).join(''))); var forwardTo = ((observer) => (value) => { observer.next(value); }); var partial = ((f, ...headArgs) => (...b) => f(...headArgs, ...b)); var assert = __webpack_require__(4); var assert_default = __webpack_require__.n(assert); var tapIs = ((constructor, x) => { assert_default()(x instanceof constructor); return x; }); var SortComponent = (class { constructor(initialCondition, defaultCondition, initialPageCount) { this.conditionInputInput$ = new external_rxjs_["Subject"](); this.conditionInputChange$ = new external_rxjs_["Subject"](); this.conditionInputKeydown$ = new external_rxjs_["Subject"](); this.sortButtonClick$ = new external_rxjs_["Subject"](); this.conditionInputEnterDown$ = this.conditionInputKeydown$.pipe(Object(external_rxjs_operators_["filter"])((e) => e.key === 'Enter')); this.resetDefaultButtonClick$ = new external_rxjs_["Subject"](); this.conditionChange$ = Object(external_rxjs_["merge"])(this.conditionInputChange$, this.conditionInputEnterDown$, this.sortButtonClick$); this.sort$ = Object(external_rxjs_["merge"])(this.sortButtonClick$, this.conditionInputEnterDown$, this.resetDefaultButtonClick$).pipe(Object(external_rxjs_operators_["map"])(() => this.state.condition)); this.condition$ = this.conditionChange$.pipe(Object(external_rxjs_operators_["startWith"])(undefined), Object(external_rxjs_operators_["map"])(() => this.state.condition)); this.pageCountInputInput$ = new external_rxjs_["Subject"](); this.pageCountInputChange$ = new external_rxjs_["Subject"](); this.defaultCondition = defaultCondition; this.state = { condition: initialCondition, pageCount: initialPageCount, pageCountChanged: false, loadedPageCount: 0, }; Object(external_rxjs_["merge"])(this.conditionInputInput$.pipe(Object(external_rxjs_operators_["pluck"])('currentTarget'), Object(external_rxjs_operators_["map"])(partial(tapIs, HTMLInputElement)), Object(external_rxjs_operators_["pluck"])('value'), Object(external_rxjs_operators_["tap"])((value) => { this.state.condition = value; })), Object(external_rxjs_["merge"])(this.conditionChange$, this.resetDefaultButtonClick$.pipe(Object(external_rxjs_operators_["tap"])(() => { this.state.condition = defaultCondition; }))).pipe(Object(external_rxjs_operators_["map"])(() => this.state.condition), Object(external_rxjs_operators_["tap"])((value) => GM.setValue('sortValue', value))), this.pageCountInputInput$.pipe(Object(external_rxjs_operators_["pluck"])('currentTarget'), Object(external_rxjs_operators_["map"])(partial(tapIs, HTMLInputElement)), Object(external_rxjs_operators_["map"])((input) => Number.parseInt(input.value, 10)), Object(external_rxjs_operators_["tap"])((pageCount) => { this.state.pageCount = pageCount; })), this.pageCountInputChange$.pipe(Object(external_rxjs_operators_["tap"])(() => { this.state.pageCountChanged = true; }), Object(external_rxjs_operators_["tap"])(() => GM.setValue('pageCount', this.state.pageCount)))).subscribe(); } view() { const commonStyle = { margin: '5px 2px', }; const conditionDataListId = 'iwara-custom-sort-conditions'; const uiChildren = { conditionInput: external_m_default()(`input${classAttr([ 'form-control', 'input-sm', ])}`, { maxLength: 120, size: 65, value: this.state.condition, style: commonStyle, list: conditionDataListId, oninput: forwardTo(this.conditionInputInput$), onchange: forwardTo(this.conditionInputChange$), onkeydown: forwardTo(this.conditionInputKeydown$), }), conditionDatalist: external_m_default()('datalist', { id: conditionDataListId, }, [ [ ['Default Condition', this.defaultCondition], ['Original Order', '-index'], ['Reversed Original Order', 'index'], ].map(([name, value]) => external_m_default()('option', { value, }, name)), ]), resetDefaultButton: external_m_default()(`button${classAttr([ 'btn', 'btn-sm', 'btn-info', ])}`, { style: commonStyle, onclick: forwardTo(this.resetDefaultButtonClick$), }, 'Default'), sortButton: external_m_default()(`button${classAttr([ 'btn', 'btn-sm', 'btn-primary', ])}`, { style: commonStyle, onclick: forwardTo(this.sortButtonClick$), }, 'Sort'), label1: external_m_default()(`label${classAttr(['text-primary'])}`, { style: commonStyle, }, `${this.state.loadedPageCount} of `), pageCountInput: external_m_default()(`input${classAttr([ 'form-control', 'input-sm', ])}`, { type: 'number', value: this.state.pageCount, min: 1, max: 500, step: 1, style: Object.assign({ width: '7rem' }, commonStyle), oninput: forwardTo(this.pageCountInputInput$), onchange: forwardTo(this.pageCountInputChange$), }), label2: external_m_default()(`label${classAttr(['text-primary'])}`, { style: commonStyle, }, 'pages loaded'), refreshLabel: external_m_default()(`label${classAttr(['text-primary'])}`, { style: commonStyle, }, this.state.pageCountChanged ? 'Refresh to apply the change.' : ''), }; const ui = external_m_default()(`div${classAttr([ 'form-inline', 'container', ])}`, { style: { display: 'inline-block', }, }, Object.values(uiChildren)); return ui; } addLoadedPageCount() { this.state.loadedPageCount += 1; external_m_default.a.redraw(); } }); var changeAnchorUrlParam = ((anchor, key, value) => { const newURL = new URL(anchor.href, window.location.href); newURL.searchParams.set(key, value); anchor.href = newURL.href; }); var createPageContainer = ((userAgent) => (document.createElement(userAgent.indexOf('Firefox') > -1 ? 'embed' : 'iframe'))); const getNumberParam = (URL_, name) => { const param = URL_.searchParams.get(name); return param ? Number.parseInt(param, 10) : 0; }; var getPageParam = ((URL_) => getNumberParam(URL_, 'page')); var reloadImage = ((image) => { const { src, } = image; image.src = ''; image.src = src; }); var removeEmbeddedPage = ((page) => { page.src = ''; page.remove(); }); function identity(a) { return a; } var unsafeCoerce = identity; function not(predicate) { return function (a) { return !predicate(a); }; } function constant(a) { return function () { return a; }; } var constTrue = function () { return true; }; var constFalse = function () { return false; }; var constNull = function () { return null; }; var constUndefined = function () { return; }; var constVoid = function () { return; }; function flip(f) { return function (b, a) { return f(a, b); }; } function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) { switch (arguments.length) { case 1: return ab; case 2: return function () { return bc(ab.apply(this, arguments)); }; case 3: return function () { return cd(bc(ab.apply(this, arguments))); }; case 4: return function () { return de(cd(bc(ab.apply(this, arguments)))); }; case 5: return function () { return ef(de(cd(bc(ab.apply(this, arguments))))); }; case 6: return function () { return fg(ef(de(cd(bc(ab.apply(this, arguments)))))); }; case 7: return function () { return gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))); }; case 8: return function () { return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))); }; case 9: return function () { return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))); }; } return; } function tuple() { var t = []; for (var _i = 0; _i < arguments.length; _i++) { t[_i] = arguments[_i]; } return t; } function increment(n) { return n + 1; } function decrement(n) { return n - 1; } function absurd(_) { throw new Error('Called `absurd` function which should be uncallable'); } function tupled(f) { return function (a) { return f.apply(void 0, a); }; } function untupled(f) { return function () { var a = []; for (var _i = 0; _i < arguments.length; _i++) { a[_i] = arguments[_i]; } return f(a); }; } function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) { switch (arguments.length) { case 1: return a; case 2: return ab(a); case 3: return bc(ab(a)); case 4: return cd(bc(ab(a))); case 5: return de(cd(bc(ab(a)))); case 6: return ef(de(cd(bc(ab(a))))); case 7: return fg(ef(de(cd(bc(ab(a)))))); case 8: return gh(fg(ef(de(cd(bc(ab(a))))))); case 9: return hi(gh(fg(ef(de(cd(bc(ab(a)))))))); case 10: return ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))); case 11: return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))); case 12: return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))); case 13: return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))); case 14: return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))); case 15: return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))); case 16: return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))); case 17: return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))); case 18: return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))); case 19: return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))); case 20: return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))))); } return; } var hole = absurd; var bind_ = function (a, name, b) { var _a; return Object.assign({}, a, (_a = {}, _a[name] = b, _a)); }; var bindTo_ = function (name) { return function (b) { var _a; return (_a = {}, _a[name] = b, _a); }; }; var isSome = function (fa) { return fa._tag === 'Some'; }; var isNone = function (fa) { return fa._tag === 'None'; }; var none = { _tag: 'None' }; var some = function (a) { return ({ _tag: 'Some', value: a }); }; function fromNullable(a) { return a == null ? none : some(a); } function fromPredicate(predicate) { return function (a) { return (predicate(a) ? some(a) : none); }; } function tryCatch(f) { try { return some(f()); } catch (e) { return none; } } function getLeft(ma) { return ma._tag === 'Right' ? none : some(ma.left); } function getRight(ma) { return ma._tag === 'Left' ? none : some(ma.right); } var fromEither = function (ma) { return (ma._tag === 'Left' ? none : some(ma.right)); }; function fold(onNone, onSome) { return function (ma) { return (isNone(ma) ? onNone() : onSome(ma.value)); }; } function toNullable(ma) { return isNone(ma) ? null : ma.value; } function toUndefined(ma) { return isNone(ma) ? undefined : ma.value; } var getOrElseW = function (onNone) { return function (ma) { return (isNone(ma) ? onNone() : ma.value); }; }; var getOrElse = getOrElseW; function mapNullable(f) { return function (ma) { return (isNone(ma) ? none : fromNullable(f(ma.value))); }; } var map_ = function (fa, f) { return (isNone(fa) ? none : some(f(fa.value))); }; var ap_ = function (fab, fa) { return (isNone(fab) ? none : isNone(fa) ? none : some(fab.value(fa.value))); }; var chain_ = function (ma, f) { return (isNone(ma) ? none : f(ma.value)); }; var reduce_ = function (fa, b, f) { return (isNone(fa) ? b : f(b, fa.value)); }; var foldMap_ = function (M) { return function (fa, f) { return (isNone(fa) ? M.empty : f(fa.value)); }; }; var reduceRight_ = function (fa, b, f) { return (isNone(fa) ? b : f(fa.value, b)); }; var traverse_ = function (F) { return function (ta, f) { return isNone(ta) ? F.of(none) : F.map(f(ta.value), some); }; }; var alt_ = function (fa, that) { return (isNone(fa) ? that() : fa); }; var filter_ = function (fa, predicate) { return isNone(fa) ? none : predicate(fa.value) ? fa : none; }; var filterMap_ = function (ma, f) { return (isNone(ma) ? none : f(ma.value)); }; var extend_ = function (wa, f) { return (isNone(wa) ? none : some(f(wa))); }; var partition_ = function (fa, predicate) { return { left: filter_(fa, function (a) { return !predicate(a); }), right: filter_(fa, predicate) }; }; var partitionMap_ = function (fa, f) { return separate(map_(fa, f)); }; var wither_ = function (F) { return function (fa, f) { return isNone(fa) ? F.of(none) : f(fa.value); }; }; var wilt_ = function (F) { return function (fa, f) { var o = map_(fa, function (a) { return F.map(f(a), function (e) { return ({ left: getLeft(e), right: getRight(e) }); }); }); return isNone(o) ? F.of({ left: none, right: none }) : o.value; }; }; var map = function (f) { return function (fa) { return map_(fa, f); }; }; var ap = function (fa) { return function (fab) { return ap_(fab, fa); }; }; var apFirst = function (fb) { return flow(map(function (a) { return function () { return a; }; }), ap(fb)); }; var apSecond = function (fb) { return flow(map(function () { return function (b) { return b; }; }), ap(fb)); }; var of = some; var chain = function (f) { return function (ma) { return chain_(ma, f); }; }; var chainFirst = function (f) { return chain(function (a) { return pipe(f(a), map(function () { return a; })); }); }; var flatten = chain(identity); var alt = function (that) { return function (fa) { return alt_(fa, that); }; }; var zero = function () { return none; }; var throwError = function () { return none; }; var extend = function (f) { return function (ma) { return extend_(ma, f); }; }; var duplicate = extend(identity); var reduce = function (b, f) { return function (fa) { return reduce_(fa, b, f); }; }; var foldMap = function (M) { var foldMapM = foldMap_(M); return function (f) { return function (fa) { return foldMapM(fa, f); }; }; }; var reduceRight = function (b, f) { return function (fa) { return reduceRight_(fa, b, f); }; }; var compact = flatten; var defaultSeparate = { left: none, right: none }; var separate = function (ma) { var o = map_(ma, function (e) { return ({ left: getLeft(e), right: getRight(e) }); }); return isNone(o) ? defaultSeparate : o.value; }; var filter = function (predicate) { return function (fa) { return filter_(fa, predicate); }; }; var filterMap = function (f) { return function (fa) { return filterMap_(fa, f); }; }; var partition = function (predicate) { return function (fa) { return partition_(fa, predicate); }; }; var partitionMap = function (f) { return function (fa) { return partitionMap_(fa, f); }; }; var traverse = function (F) { var traverseF = traverse_(F); return function (f) { return function (ta) { return traverseF(ta, f); }; }; }; var sequence = function (F) { return function (ta) { return isNone(ta) ? F.of(none) : F.map(ta.value, some); }; }; var wither = function (F) { var witherF = wither_(F); return function (f) { return function (ta) { return witherF(ta, f); }; }; }; var wilt = function (F) { var wiltF = wilt_(F); return function (f) { return function (ta) { return wiltF(ta, f); }; }; }; var URI = 'Option'; function getShow(S) { return { show: function (ma) { return (isNone(ma) ? 'none' : "some(" + S.show(ma.value) + ")"); } }; } function getEq(E) { return { equals: function (x, y) { return x === y || (isNone(x) ? isNone(y) : isNone(y) ? false : E.equals(x.value, y.value)); } }; } function getOrd(O) { return { equals: getEq(O).equals, compare: function (x, y) { return (x === y ? 0 : isSome(x) ? (isSome(y) ? O.compare(x.value, y.value) : 1) : -1); } }; } function getApplySemigroup(S) { return { concat: function (x, y) { return (isSome(x) && isSome(y) ? some(S.concat(x.value, y.value)) : none); } }; } function getApplyMonoid(M) { return { concat: getApplySemigroup(M).concat, empty: some(M.empty) }; } function getFirstMonoid() { return { concat: function (x, y) { return (isNone(x) ? y : x); }, empty: none }; } function getLastMonoid() { return { concat: function (x, y) { return (isNone(y) ? x : y); }, empty: none }; } function getMonoid(S) { return { concat: function (x, y) { return (isNone(x) ? y : isNone(y) ? x : some(S.concat(x.value, y.value))); }, empty: none }; } var Functor = { URI: URI, map: map_ }; var Applicative = { URI: URI, map: map_, ap: ap_, of: of }; var Monad = { URI: URI, map: map_, ap: ap_, of: of, chain: chain_ }; var Foldable = { URI: URI, reduce: reduce_, foldMap: foldMap_, reduceRight: reduceRight_ }; var Alt = { URI: URI, map: map_, alt: alt_ }; var Alternative = { URI: URI, map: map_, ap: ap_, of: of, alt: alt_, zero: zero }; var Extend = { URI: URI, map: map_, extend: extend_ }; var Compactable = { URI: URI, compact: compact, separate: separate }; var Filterable = { URI: URI, map: map_, compact: compact, separate: separate, filter: filter_, filterMap: filterMap_, partition: partition_, partitionMap: partitionMap_ }; var Traversable = { URI: URI, map: map_, reduce: reduce_, foldMap: foldMap_, reduceRight: reduceRight_, traverse: traverse_, sequence: sequence }; var Witherable = { URI: URI, map: map_, reduce: reduce_, foldMap: foldMap_, reduceRight: reduceRight_, traverse: traverse_, sequence: sequence, compact: compact, separate: separate, filter: filter_, filterMap: filterMap_, partition: partition_, partitionMap: partitionMap_, wither: wither_, wilt: wilt_ }; var MonadThrow = { URI: URI, map: map_, ap: ap_, of: of, chain: chain_, throwError: throwError }; var Option_option = { URI: URI, map: map_, of: of, ap: ap_, chain: chain_, reduce: reduce_, foldMap: foldMap_, reduceRight: reduceRight_, traverse: traverse_, sequence: sequence, zero: zero, alt: alt_, extend: extend_, compact: compact, separate: separate, filter: filter_, filterMap: filterMap_, partition: partition_, partitionMap: partitionMap_, wither: wither_, wilt: wilt_, throwError: throwError }; function elem(E) { return function (a, ma) { return (isNone(ma) ? false : E.equals(a, ma.value)); }; } function exists(predicate) { return function (ma) { return (isNone(ma) ? false : predicate(ma.value)); }; } function getRefinement(getOption) { return function (a) { return isSome(getOption(a)); }; } var bindTo = function (name) { return map(bindTo_(name)); }; var bind = function (name, f) { return chain(function (a) { return pipe(f(a), map(function (b) { return bind_(a, name, b); })); }); }; var apS = function (name, fb) { return flow(map(function (a) { return function (b) { return bind_(a, name, b); }; }), ap(fb)); }; var lib_function = __webpack_require__(7); var tapNonNull = ((x) => { assert_default()(x); return x; }); const getTeaserValue = (info, condition) => { const sortParamPairs = [ ['index', info.initialIndex], ['views', info.viewCount], ['likes', info.likeCount], ['ratio', Math.min(info.likeCount / Math.max(1, info.viewCount), 1)], ['image', info.imageFactor], ['gallery', info.galleryFactor], ['private', info.privateFactor], ]; return new Function(...sortParamPairs.map(([name]) => name), `return (${condition})`)(...sortParamPairs.map((pair) => pair[1])); }; var sortTeaser = ((container, condition) => { const viewsIconSelector = '.glyphicon-eye-open'; const likesIconSelector = '.glyphicon-heart'; const imageFieldSelector = '.field-type-image'; const galleryIconSelector = '.glyphicon-th-large'; const privateDivSelector = '.private-video'; const teaserDivs = Array.from(container.querySelectorAll(teaserElementSelector)); const sortedTeaserCount = container.dataset.sortedTeaserCount ? parseInt(container.dataset.sortedTeaserCount, 10) : 0; teaserDivs.filter(({ dataset, }) => !dataset.initialIndex) .forEach(({ dataset, }, index) => { dataset.initialIndex = (sortedTeaserCount + index).toString(); }); container.dataset.sortedTeaserCount = teaserDivs.length.toString(); const getNearbyNumber = (element) => { const parseSuffixed = (str) => Number.parseFloat(str) * (str.includes('k') ? 1000 : 1); return parseSuffixed(tapIs(Text, element.nextSibling).wholeText.replace(/,/g, '')); }; const nearbyNumberOrZero = (element) => Object(lib_function["pipe"])(fromNullable(element), map(getNearbyNumber), getOrElse(() => 0)); const teaserInfos = teaserDivs.map((div) => ({ initialIndex: parseInt(tapNonNull(div.dataset.initialIndex), 10), viewCount: nearbyNumberOrZero(div.querySelector(viewsIconSelector)), likeCount: nearbyNumberOrZero(div.querySelector(likesIconSelector)), imageFactor: div.querySelector(imageFieldSelector) ? 1 : 0, galleryFactor: div.querySelector(galleryIconSelector) ? 1 : 0, privateFactor: div.querySelector(privateDivSelector) ? 1 : 0, })); const divValuePairs = teaserInfos.map((info, index) => [ teaserDivs[index], getTeaserValue(info, condition), ]); divValuePairs.sort((itemA, itemB) => itemB[1] - itemA[1]); teaserDivs.forEach((div) => div.after(document.createElement('span'))); teaserDivs.map((div) => tapNonNull(div.nextSibling)).forEach((anchor, index) => anchor.replaceWith(divValuePairs[index][0])); }); const changeAnchorPageParam = (anchor, value) => changeAnchorUrlParam(anchor, 'page', value.toString()); const groupCurrentPageItems = (currentPageItems) => { const parentItem = document.createElement('li'); currentPageItems[0].before(parentItem); currentPageItems[0].style.marginLeft = '0'; const groupList = document.createElement('ul'); groupList.style.display = 'inline'; groupList.style.backgroundColor = 'hsla(0, 0%, 75%, 50%)'; currentPageItems.forEach(({ classList, }) => classList.replace('pager-item', 'pager-current')); groupList.append(...currentPageItems); parentItem.append(groupList); }; const adjustPageAnchors = (container, pageCount) => { const currentPage = getPageParam(new URL(window.location.href)); if (currentPage > 0) { const previousPageAnchor = container.querySelector('.pager-previous a'); changeAnchorPageParam(tapNonNull(previousPageAnchor), Math.max(0, currentPage - pageCount)); } const nextPage = currentPage + pageCount; { const nextPageAnchor = container.querySelector('.pager-next a'); const lastPageAnchor = container.querySelector('.pager-last a'); if (lastPageAnchor && getPageParam(new URL(lastPageAnchor.href, window.location.href)) < nextPage) { tapNonNull(nextPageAnchor).remove(); lastPageAnchor.remove(); } else if (nextPageAnchor) { changeAnchorPageParam(nextPageAnchor, nextPage); } } const currentPageAnchors = Array.from(container.querySelectorAll('.pager-item a')).filter(({ href, }) => { const page = getPageParam(new URL(href, window.location.href)); return page >= currentPage && page < nextPage; }); if (currentPageAnchors.length > 0) { const currentPageItems = [ ...Array.from(container.querySelectorAll('.pager-current')), ...currentPageAnchors.map((anchor) => tapNonNull(anchor.parentElement)), ]; groupCurrentPageItems(currentPageItems); } }; const getBrokenImages = () => getTeaserContainers(document).flatMap((container) => Array.from(container.querySelectorAll('img'))).filter((img) => img.complete && img.naturalWidth === 0); const createPreloadPage = (createContainer, url) => { const container = createContainer(); container.src = url.toString(); container.style.display = 'hidden'; return container; }; const createPreloadUrls = (startURL, pageCount) => { const currentURL = startURL; const currentPage = getPageParam(currentURL); return [...Array(pageCount).keys()].map((i) => { currentURL.searchParams.set('page', (i + currentPage + 1).toString()); return new URL('', currentURL); }); }; const trySortTeasers = (condition$) => condition$.pipe(Object(external_rxjs_operators_["map"])((condition) => [getTeaserContainers(document), condition]), Object(external_rxjs_operators_["mergeMap"])((x) => Object(external_rxjs_["of"])(x).pipe(Object(external_rxjs_operators_["tap"])(([containers, condition]) => containers.forEach((container) => sortTeaser(container, condition))), Object(external_rxjs_operators_["catchError"])((error) => { external_Swal_default.a.fire('Sorting Failed', `An error accured while sorting: ${error.toString()}`); external_log_["error"](error); return external_rxjs_["EMPTY"]; }))), Object(external_rxjs_operators_["map"])(([containers]) => ({ containersCount: containers.length, }))); var initParent = (async () => { if (getTeaserContainers(document).length === 0) { return; } const defaultCondition = '(ratio / (private * 2.0 + 1)' + ' + Math.log(likes) / 220) / (image + 8.0)'; const initialCondition = tapNonNull(await GM.getValue('sortValue', defaultCondition)); const pageCount = tapNonNull(await GM.getValue('pageCount', 1)); const haveMorePages = document.querySelector('.pager') && !document.querySelector('#comments'); if (haveMorePages) { document.querySelectorAll('.pager').forEach((pager) => adjustPageAnchors(pager, pageCount)); } const preloadUrls = haveMorePages ? createPreloadUrls(new URL(window.location.href), pageCount - 1) : []; const channel = new BroadcastChannel(scriptChannelName); const pageLoad$ = Object(external_rxjs_["fromEvent"])(channel, 'message').pipe(Object(external_rxjs_operators_["pluck"])('data')); const teaserPageLoad$ = pageLoad$.pipe(Object(external_rxjs_operators_["filter"])((message) => message.hasTeasers)); const pageFromUrl = new Map(); const unsortedTeasers$ = teaserPageLoad$.pipe(Object(external_rxjs_operators_["mapTo"])(undefined), Object(external_rxjs_operators_["startWith"])(undefined)); const sortComponent = new SortComponent(initialCondition, defaultCondition, pageCount); const allStreams = { logPageLoad$: pageLoad$.pipe(Object(external_rxjs_operators_["tap"])(external_log_["info"])), reloadBrokenImages$: unsortedTeasers$.pipe(Object(external_rxjs_operators_["mergeMap"])(() => Object(external_rxjs_["timer"])(0, 8000).pipe(Object(external_rxjs_operators_["take"])(2))), Object(external_rxjs_operators_["auditTime"])(6000), Object(external_rxjs_operators_["map"])(getBrokenImages), Object(external_rxjs_operators_["tap"])((images) => images.forEach(reloadImage)), Object(external_rxjs_operators_["map"])((images) => `Reload ${images.length} broken image(s)`), Object(external_rxjs_operators_["tap"])(external_log_["info"])), sortTeasers$: Object(external_rxjs_["merge"])(unsortedTeasers$.pipe(Object(external_rxjs_operators_["withLatestFrom"])(sortComponent.condition$), Object(external_rxjs_operators_["map"])(([, condition]) => condition), Object(external_rxjs_operators_["tap"])(() => sortComponent.addLoadedPageCount())), sortComponent.sort$).pipe(trySortTeasers, Object(external_rxjs_operators_["map"])((result) => `${result.containersCount} containers sorted`), Object(external_rxjs_operators_["tap"])(external_log_["info"])), removeLoadedPage$: pageLoad$.pipe(Object(external_rxjs_operators_["map"])(({ url, }) => ({ url, container: pageFromUrl.get(url), })), Object(external_rxjs_operators_["tap"])(({ url, }) => pageFromUrl.delete(url)), Object(external_rxjs_operators_["pluck"])('container'), Object(external_rxjs_operators_["map"])(tapNonNull), Object(external_rxjs_operators_["tap"])(removeEmbeddedPage)), addHiddenPreload$: Object(external_rxjs_["zip"])(Object(external_rxjs_["from"])(preloadUrls), teaserPageLoad$.pipe(Object(external_rxjs_operators_["mapTo"])(undefined), Object(external_rxjs_operators_["startWith"])(...Array.from({ length: 5, }, () => undefined)))).pipe(Object(external_rxjs_operators_["map"])(([url]) => [ url, () => createPageContainer(window.navigator.userAgent), ]), Object(external_rxjs_operators_["map"])(([url, createContainer]) => [ url.toString(), createPreloadPage(createContainer, url), ]), Object(external_rxjs_operators_["tap"])((entry) => pageFromUrl.set(...entry)), Object(external_rxjs_operators_["tap"])(([, container]) => document.body.append(container))), }; const all$ = Object(external_rxjs_["merge"])(...Object.values(allStreams)); all$.subscribe(); const sortComponentContainer = document.createElement('div'); const parent = tapNonNull(document.querySelector('#user-links')); parent.after(sortComponentContainer); external_m_default.a.mount(sortComponentContainer, sortComponent); external_log_["debug"](await GM.listValues()); }); var initialize = (async () => { const isParent = (window === window.parent); external_log_["debug"](`${isParent ? 'Parent' : 'Child'}: ${window.location.href}`); await (isParent ? initParent() : initChild()); }); (async () => { external_log_["setLevel"]('debug'); try { await initialize(); } catch (error) { external_log_["error"](error); } })(); }) ]);