Iwara Custom Sort

Automatically sort teaser images on /videos, /images, /subscriptions, /users, /playlist, and sidebars using customizable sort function. Can load and sort multiple pages at once.

当前为 2021-02-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Iwara Custom Sort
  3. // @version 1.0.9
  4. // @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.
  5. // @match http://ecchi.iwara.tv/*
  6. // @match https://ecchi.iwara.tv/*
  7. // @match http://www.iwara.tv/*
  8. // @match https://www.iwara.tv/*
  9. // @name:ja Iwara Custom ソート
  10. // @run-at document-end
  11. // @grant GM.setValue
  12. // @grant GM.getValue
  13. // @grant GM.deleteValue
  14. // @grant GM.listValues
  15. // @license AGPL-3.0-or-later
  16. // @description:ja /videos、/images、/subscriptions、/users、/playlistとサイドバーのサムネイルを自動的にソートします。ソート方法はカスタマイズすることができます、一度に複数のページを読み込んでソートすることができます。
  17. // @require https://cdn.jsdelivr.net/npm/sweetalert2@10.10.1/dist/sweetalert2.all.min.js#sha384-OCBhaEdUu7BFgaeRVey2PDeHof2MSQRFe/e6S8Q3XrmSV7wrKpLmhPj8FOldGiaF
  18. // @require https://unpkg.com/loglevel@1.7.0/dist/loglevel.min.js#sha384-7gGuWfek8Ql6j/uNDFrS0BCe4x2ZihD4B68w9Eu580OVHJBV+bl3rZmEWC7q5/Gj
  19. // @require https://unpkg.com/rxjs@7.0.0-beta.10/dist/bundles/rxjs.umd.min.js#sha384-+BwV2u+ZJFwj586/3PlpsZdYS1U/+hT/zpjYSznHH4XzUJqgshDzZITJ+zGeWl//
  20. // @require https://unpkg.com/mithril@2.0.4/mithril.min.js#sha384-vo9crXih40MlEv6JWHqS7SsPiFp+76csaWQFOF2UU0/xI58Jm/ZvK/1UtpaicJT9
  21. // @namespace https://gf.qytechs.cn/users/245195
  22. // ==/UserScript==
  23.  
  24. /* jshint esversion: 6 */
  25.  
  26. ;(() => {
  27. var __webpack_modules__ = {
  28. 494: function (module, exports, __webpack_require__) {
  29. var __WEBPACK_AMD_DEFINE_RESULT__
  30. !(function (globals) {
  31. "use strict"
  32. var messages,
  33. predicates,
  34. functions,
  35. assert,
  36. not,
  37. maybe,
  38. collections,
  39. hasOwnProperty,
  40. toString,
  41. keys,
  42. slice,
  43. isArray,
  44. neginf,
  45. posinf,
  46. haveSymbols,
  47. haveMaps,
  48. haveSets
  49. function assigned(data) {
  50. return null != data
  51. }
  52. function number(data) {
  53. return "number" == typeof data && data > neginf && data < posinf
  54. }
  55. function integer(data) {
  56. return "number" == typeof data && data % 1 == 0
  57. }
  58. function greater(lhs, rhs) {
  59. return number(lhs) && lhs > rhs
  60. }
  61. function less(lhs, rhs) {
  62. return number(lhs) && lhs < rhs
  63. }
  64. function greaterOrEqual(lhs, rhs) {
  65. return number(lhs) && lhs >= rhs
  66. }
  67. function lessOrEqual(lhs, rhs) {
  68. return number(lhs) && lhs <= rhs
  69. }
  70. function string(data) {
  71. return "string" == typeof data
  72. }
  73. function nonEmptyString(data) {
  74. return string(data) && "" !== data
  75. }
  76. function object(data) {
  77. return "[object Object]" === toString.call(data)
  78. }
  79. function some(data, predicate) {
  80. for (var key in data)
  81. if (hasOwnProperty.call(data, key) && predicate(key, data[key]))
  82. return !0
  83. return !1
  84. }
  85. function instanceStrict(data, prototype) {
  86. try {
  87. return data instanceof prototype
  88. } catch (error) {
  89. return !1
  90. }
  91. }
  92. function like(data, archetype) {
  93. var name
  94. for (name in archetype)
  95. if (hasOwnProperty.call(archetype, name)) {
  96. if (
  97. !1 === hasOwnProperty.call(data, name) ||
  98. typeof data[name] != typeof archetype[name]
  99. )
  100. return !1
  101. if (
  102. object(data[name]) &&
  103. !1 === like(data[name], archetype[name])
  104. )
  105. return !1
  106. }
  107. return !0
  108. }
  109. function arrayLike(data) {
  110. return assigned(data) && data.length >= 0
  111. }
  112. function iterable(data) {
  113. return haveSymbols
  114. ? assigned(data) && isFunction(data[Symbol.iterator])
  115. : arrayLike(data)
  116. }
  117. function contains(data, value) {
  118. var iterator, iteration
  119. if (!assigned(data)) return !1
  120. if (haveSets && instanceStrict(data, Set)) return data.has(value)
  121. if (string(data)) return -1 !== data.indexOf(value)
  122. if (
  123. haveSymbols &&
  124. data[Symbol.iterator] &&
  125. isFunction(data.values)
  126. ) {
  127. iterator = data.values()
  128. do {
  129. if ((iteration = iterator.next()).value === value) return !0
  130. } while (!iteration.done)
  131. return !1
  132. }
  133. return some(data, function (key, dataValue) {
  134. return dataValue === value
  135. })
  136. }
  137. function containsKey(data, key) {
  138. return (
  139. !!assigned(data) &&
  140. (haveMaps && instanceStrict(data, Map)
  141. ? data.has(key)
  142. : !(iterable(data) && !number(+key)) && !!data[key])
  143. )
  144. }
  145. function isFunction(data) {
  146. return "function" == typeof data
  147. }
  148. function forEach(object, action) {
  149. for (var key in object)
  150. hasOwnProperty.call(object, key) && action(key, object[key])
  151. }
  152. function testArray(data, result) {
  153. var i
  154. for (i = 0; i < data.length; i += 1)
  155. if (data[i] === result) return result
  156. return !result
  157. }
  158. function testObject(data, result) {
  159. var key, value
  160. for (key in data)
  161. if (hasOwnProperty.call(data, key)) {
  162. if (
  163. object((value = data[key])) &&
  164. testObject(value, result) === result
  165. )
  166. return result
  167. if (value === result) return result
  168. }
  169. return !result
  170. }
  171. function mixin(target, source) {
  172. return (
  173. forEach(source, function (key, value) {
  174. target[key] = value
  175. }),
  176. target
  177. )
  178. }
  179. function assertModifier(predicate, defaultMessage) {
  180. return function () {
  181. var args = arguments,
  182. argCount = predicate.l || predicate.length,
  183. message = args[argCount],
  184. ErrorType = args[argCount + 1]
  185. return (
  186. assertImpl(
  187. predicate.apply(null, args),
  188. nonEmptyString(message)
  189. ? message
  190. : defaultMessage
  191. .replace("{a}", messageFormatter(args[0]))
  192. .replace("{e}", messageFormatter(args[1]))
  193. .replace("{e2}", messageFormatter(args[2]))
  194. .replace("{t}", function () {
  195. var arg = args[1]
  196. return arg && arg.name ? arg.name : arg
  197. }),
  198. isFunction(ErrorType) ? ErrorType : TypeError
  199. ),
  200. args[0]
  201. )
  202. }
  203. }
  204. function messageFormatter(arg) {
  205. return function () {
  206. return string(arg)
  207. ? '"' + arg.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"'
  208. : arg &&
  209. !0 !== arg &&
  210. arg.constructor &&
  211. !instanceStrict(arg, RegExp) &&
  212. "number" != typeof arg
  213. ? arg.constructor.name
  214. : arg
  215. }
  216. }
  217. function assertImpl(value, message, ErrorType) {
  218. if (value) return value
  219. throw new (ErrorType || Error)(message || "assert failed")
  220. }
  221. function notModifier(predicate) {
  222. var modifiedPredicate = function () {
  223. return notImpl(predicate.apply(null, arguments))
  224. }
  225. return (modifiedPredicate.l = predicate.length), modifiedPredicate
  226. }
  227. function notImpl(value) {
  228. return !value
  229. }
  230. function ofModifier(target, type, predicate) {
  231. var modifiedPredicate = function () {
  232. var collection, args
  233. if (
  234. ((collection = arguments[0]),
  235. "maybe" === target && not.assigned(collection))
  236. )
  237. return !0
  238. if (!type(collection)) return !1
  239. ;(collection = coerceCollection(type, collection)),
  240. (args = slice.call(arguments, 1))
  241. try {
  242. collection.forEach(function (item) {
  243. if (
  244. ("maybe" !== target || assigned(item)) &&
  245. !predicate.apply(null, [item].concat(args))
  246. )
  247. throw 0
  248. })
  249. } catch (ignore) {
  250. return !1
  251. }
  252. return !0
  253. }
  254. return (modifiedPredicate.l = predicate.length), modifiedPredicate
  255. }
  256. function coerceCollection(type, collection) {
  257. switch (type) {
  258. case arrayLike:
  259. return slice.call(collection)
  260. case object:
  261. return keys(collection).map(function (key) {
  262. return collection[key]
  263. })
  264. default:
  265. return collection
  266. }
  267. }
  268. function createModifiedPredicates(modifier, object) {
  269. return createModifiedFunctions([modifier, predicates, object, ""])
  270. }
  271. function createModifiedFunctions(args) {
  272. var modifier, messageModifier, object
  273. return (
  274. (modifier = args.shift()),
  275. (messageModifier = args.pop()),
  276. (object = args.pop()),
  277. forEach(args.pop(), function (key, fn) {
  278. var message = messages[key]
  279. message &&
  280. messageModifier &&
  281. (message = message.replace("to", messageModifier + "to")),
  282. Object.defineProperty(object, key, {
  283. configurable: !1,
  284. enumerable: !0,
  285. writable: !1,
  286. value: modifier.apply(null, args.concat(fn, message)),
  287. })
  288. }),
  289. object
  290. )
  291. }
  292. function createModifiedModifier(modifier, modified, messageModifier) {
  293. return createModifiedFunctions([
  294. modifier,
  295. modified,
  296. {},
  297. messageModifier,
  298. ])
  299. }
  300. function createOfModifiers(base, modifier) {
  301. collections.forEach(function (key) {
  302. base[key].of = createModifiedModifier(
  303. modifier,
  304. predicates[key].of
  305. )
  306. })
  307. }
  308. ;(messages = {}),
  309. (predicates = {}),
  310. [
  311. {
  312. n: "equal",
  313. f: function (lhs, rhs) {
  314. return lhs === rhs
  315. },
  316. s: "equal {e}",
  317. },
  318. {
  319. n: "undefined",
  320. f: function (data) {
  321. return void 0 === data
  322. },
  323. s: "be undefined",
  324. },
  325. {
  326. n: "null",
  327. f: function (data) {
  328. return null === data
  329. },
  330. s: "be null",
  331. },
  332. { n: "assigned", f: assigned, s: "be assigned" },
  333. {
  334. n: "primitive",
  335. f: function (data) {
  336. var type
  337. switch (data) {
  338. case null:
  339. case void 0:
  340. case !1:
  341. case !0:
  342. return !0
  343. }
  344. return (
  345. "string" === (type = typeof data) ||
  346. "number" === type ||
  347. (haveSymbols && "symbol" === type)
  348. )
  349. },
  350. s: "be primitive type",
  351. },
  352. { n: "contains", f: contains, s: "contain {e}" },
  353. {
  354. n: "in",
  355. f: function (value, data) {
  356. return contains(data, value)
  357. },
  358. s: "be in {e}",
  359. },
  360. { n: "containsKey", f: containsKey, s: "contain key {e}" },
  361. {
  362. n: "keyIn",
  363. f: function (key, data) {
  364. return containsKey(data, key)
  365. },
  366. s: "be key in {e}",
  367. },
  368. {
  369. n: "zero",
  370. f: function (data) {
  371. return 0 === data
  372. },
  373. s: "be 0",
  374. },
  375. {
  376. n: "one",
  377. f: function (data) {
  378. return 1 === data
  379. },
  380. s: "be 1",
  381. },
  382. {
  383. n: "infinity",
  384. f: function (data) {
  385. return data === neginf || data === posinf
  386. },
  387. s: "be infinity",
  388. },
  389. { n: "number", f: number, s: "be Number" },
  390. { n: "integer", f: integer, s: "be integer" },
  391. {
  392. n: "float",
  393. f: function (data) {
  394. return number(data) && data % 1 != 0
  395. },
  396. s: "be non-integer number",
  397. },
  398. {
  399. n: "even",
  400. f: function (data) {
  401. return "number" == typeof data && data % 2 == 0
  402. },
  403. s: "be even number",
  404. },
  405. {
  406. n: "odd",
  407. f: function (data) {
  408. return integer(data) && data % 2 != 0
  409. },
  410. s: "be odd number",
  411. },
  412. { n: "greater", f: greater, s: "be greater than {e}" },
  413. { n: "less", f: less, s: "be less than {e}" },
  414. {
  415. n: "between",
  416. f: function (data, x, y) {
  417. if (x < y) return greater(data, x) && data < y
  418. return less(data, x) && data > y
  419. },
  420. s: "be between {e} and {e2}",
  421. },
  422. {
  423. n: "greaterOrEqual",
  424. f: greaterOrEqual,
  425. s: "be greater than or equal to {e}",
  426. },
  427. {
  428. n: "lessOrEqual",
  429. f: lessOrEqual,
  430. s: "be less than or equal to {e}",
  431. },
  432. {
  433. n: "inRange",
  434. f: function (data, x, y) {
  435. if (x < y) return greaterOrEqual(data, x) && data <= y
  436. return lessOrEqual(data, x) && data >= y
  437. },
  438. s: "be in the range {e} to {e2}",
  439. },
  440. {
  441. n: "positive",
  442. f: function (data) {
  443. return greater(data, 0)
  444. },
  445. s: "be positive number",
  446. },
  447. {
  448. n: "negative",
  449. f: function (data) {
  450. return less(data, 0)
  451. },
  452. s: "be negative number",
  453. },
  454. { n: "string", f: string, s: "be String" },
  455. {
  456. n: "emptyString",
  457. f: function (data) {
  458. return "" === data
  459. },
  460. s: "be empty string",
  461. },
  462. {
  463. n: "nonEmptyString",
  464. f: nonEmptyString,
  465. s: "be non-empty string",
  466. },
  467. {
  468. n: "match",
  469. f: function (data, regex) {
  470. return string(data) && !!data.match(regex)
  471. },
  472. s: "match {e}",
  473. },
  474. {
  475. n: "boolean",
  476. f: function (data) {
  477. return !1 === data || !0 === data
  478. },
  479. s: "be Boolean",
  480. },
  481. { n: "object", f: object, s: "be Object" },
  482. {
  483. n: "emptyObject",
  484. f: function (data) {
  485. return (
  486. object(data) &&
  487. !some(data, function () {
  488. return !0
  489. })
  490. )
  491. },
  492. s: "be empty object",
  493. },
  494. {
  495. n: "nonEmptyObject",
  496. f: function (data) {
  497. return (
  498. object(data) &&
  499. some(data, function () {
  500. return !0
  501. })
  502. )
  503. },
  504. s: "be non-empty object",
  505. },
  506. {
  507. n: "instanceStrict",
  508. f: instanceStrict,
  509. s: "be instanceof {t}",
  510. },
  511. {
  512. n: "thenable",
  513. f: function (data) {
  514. return assigned(data) && isFunction(data.then)
  515. },
  516. s: "be promise-like",
  517. },
  518. {
  519. n: "instance",
  520. f: function (data, prototype) {
  521. try {
  522. return (
  523. instanceStrict(data, prototype) ||
  524. data.constructor.name === prototype.name ||
  525. toString.call(data) === "[object " + prototype.name + "]"
  526. )
  527. } catch (error) {
  528. return !1
  529. }
  530. },
  531. s: "be {t}",
  532. },
  533. { n: "like", f: like, s: "be like {e}" },
  534. {
  535. n: "array",
  536. f: function (data) {
  537. return isArray(data)
  538. },
  539. s: "be Array",
  540. },
  541. {
  542. n: "emptyArray",
  543. f: function (data) {
  544. return isArray(data) && 0 === data.length
  545. },
  546. s: "be empty array",
  547. },
  548. {
  549. n: "nonEmptyArray",
  550. f: function (data) {
  551. return isArray(data) && data.length > 0
  552. },
  553. s: "be non-empty array",
  554. },
  555. { n: "arrayLike", f: arrayLike, s: "be array-like" },
  556. { n: "iterable", f: iterable, s: "be iterable" },
  557. {
  558. n: "date",
  559. f: function (data) {
  560. return instanceStrict(data, Date) && integer(data.getTime())
  561. },
  562. s: "be valid Date",
  563. },
  564. { n: "function", f: isFunction, s: "be Function" },
  565. {
  566. n: "hasLength",
  567. f: function (data, length) {
  568. return assigned(data) && data.length === length
  569. },
  570. s: "have length {e}",
  571. },
  572. {
  573. n: "throws",
  574. f: function (data) {
  575. if (!isFunction(data)) return !1
  576. try {
  577. data()
  578. } catch (error) {
  579. return !0
  580. }
  581. return !1
  582. },
  583. s: "throw",
  584. },
  585. ].map(function (data) {
  586. var n = data.n
  587. ;(messages[n] = "assert failed: expected {a} to " + data.s),
  588. (predicates[n] = data.f)
  589. }),
  590. (functions = {
  591. map: function map(data, predicates) {
  592. var result
  593. result = isArray(data) ? [] : {}
  594. if (isFunction(predicates))
  595. forEach(data, function (key, value) {
  596. result[key] = predicates(value)
  597. })
  598. else {
  599. isArray(predicates) || assert.object(predicates)
  600. var dataKeys = keys(data || {})
  601. forEach(predicates, function (key, predicate) {
  602. dataKeys.some(function (dataKey, index) {
  603. return dataKey === key && (dataKeys.splice(index, 1), !0)
  604. }),
  605. isFunction(predicate)
  606. ? not.assigned(data)
  607. ? (result[key] = !!predicate.m)
  608. : (result[key] = predicate(data[key]))
  609. : (result[key] = map(data[key], predicate))
  610. })
  611. }
  612. return result
  613. },
  614. all: function (data) {
  615. if (isArray(data)) return testArray(data, !1)
  616. return assert.object(data), testObject(data, !1)
  617. },
  618. any: function (data) {
  619. if (isArray(data)) return testArray(data, !0)
  620. return assert.object(data), testObject(data, !0)
  621. },
  622. }),
  623. (collections = ["array", "arrayLike", "iterable", "object"]),
  624. (hasOwnProperty = Object.prototype.hasOwnProperty),
  625. (toString = Object.prototype.toString),
  626. (keys = Object.keys),
  627. (slice = Array.prototype.slice),
  628. (isArray = Array.isArray),
  629. (neginf = Number.NEGATIVE_INFINITY),
  630. (posinf = Number.POSITIVE_INFINITY),
  631. (haveSymbols = "function" == typeof Symbol),
  632. (haveMaps = "function" == typeof Map),
  633. (haveSets = "function" == typeof Set),
  634. (functions = mixin(functions, predicates)),
  635. (assert = createModifiedPredicates(assertModifier, assertImpl)),
  636. (not = createModifiedPredicates(notModifier, notImpl)),
  637. (maybe = createModifiedPredicates(
  638. function (predicate) {
  639. var modifiedPredicate = function () {
  640. return (
  641. !!not.assigned(arguments[0]) ||
  642. predicate.apply(null, arguments)
  643. )
  644. }
  645. return (
  646. (modifiedPredicate.l = predicate.length),
  647. (modifiedPredicate.m = !0),
  648. modifiedPredicate
  649. )
  650. },
  651. function (value) {
  652. if (!1 === assigned(value)) return !0
  653. return value
  654. }
  655. )),
  656. (assert.not = createModifiedModifier(assertModifier, not, "not ")),
  657. (assert.maybe = createModifiedModifier(
  658. assertModifier,
  659. maybe,
  660. "maybe "
  661. )),
  662. collections.forEach(function (key) {
  663. predicates[key].of = createModifiedFunctions([
  664. ofModifier.bind(null, null),
  665. predicates[key],
  666. predicates,
  667. {},
  668. "",
  669. ])
  670. }),
  671. createOfModifiers(assert, assertModifier),
  672. createOfModifiers(not, notModifier),
  673. collections.forEach(function (key) {
  674. ;(maybe[key].of = createModifiedFunctions([
  675. ofModifier.bind(null, "maybe"),
  676. predicates[key],
  677. predicates,
  678. {},
  679. "",
  680. ])),
  681. (assert.maybe[key].of = createModifiedModifier(
  682. assertModifier,
  683. maybe[key].of
  684. )),
  685. (assert.not[key].of = createModifiedModifier(
  686. assertModifier,
  687. not[key].of
  688. ))
  689. }),
  690. (function (functions) {
  691. void 0 ===
  692. (__WEBPACK_AMD_DEFINE_RESULT__ = function () {
  693. return functions
  694. }.call(exports, __webpack_require__, exports, module)) ||
  695. (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)
  696. })(mixin(functions, { assert, not, maybe }))
  697. })()
  698. },
  699. 228: module => {
  700. "use strict"
  701. const createAbortError = () => {
  702. const error = new Error("Delay aborted")
  703. return (error.name = "AbortError"), error
  704. },
  705. createDelay = ({
  706. clearTimeout: defaultClear,
  707. setTimeout: set,
  708. willResolve,
  709. }) => (ms, { value, signal } = {}) => {
  710. if (signal && signal.aborted)
  711. return Promise.reject(createAbortError())
  712. let timeoutId, settle, rejectFn
  713. const clear = defaultClear || clearTimeout,
  714. signalListener = () => {
  715. clear(timeoutId), rejectFn(createAbortError())
  716. },
  717. delayPromise = new Promise((resolve, reject) => {
  718. ;(settle = () => {
  719. signal && signal.removeEventListener("abort", signalListener),
  720. willResolve ? resolve(value) : reject(value)
  721. }),
  722. (rejectFn = reject),
  723. (timeoutId = (set || setTimeout)(settle, ms))
  724. })
  725. return (
  726. signal &&
  727. signal.addEventListener("abort", signalListener, { once: !0 }),
  728. (delayPromise.clear = () => {
  729. clear(timeoutId), (timeoutId = null), settle()
  730. }),
  731. delayPromise
  732. )
  733. },
  734. delay = createDelay({ willResolve: !0 })
  735. ;(delay.reject = createDelay({ willResolve: !1 })),
  736. (delay.range = (minimum, maximum, options) =>
  737. delay(
  738. ((minimum, maximum) =>
  739. Math.floor(Math.random() * (maximum - minimum + 1) + minimum))(
  740. minimum,
  741. maximum
  742. ),
  743. options
  744. )),
  745. (delay.createWithTimers = ({ clearTimeout, setTimeout }) => {
  746. const delay = createDelay({
  747. clearTimeout,
  748. setTimeout,
  749. willResolve: !0,
  750. })
  751. return (
  752. (delay.reject = createDelay({
  753. clearTimeout,
  754. setTimeout,
  755. willResolve: !1,
  756. })),
  757. delay
  758. )
  759. }),
  760. (module.exports = delay),
  761. (module.exports.default = delay)
  762. },
  763. },
  764. __webpack_module_cache__ = {}
  765. function __webpack_require__(moduleId) {
  766. if (__webpack_module_cache__[moduleId])
  767. return __webpack_module_cache__[moduleId].exports
  768. var module = (__webpack_module_cache__[moduleId] = { exports: {} })
  769. return (
  770. __webpack_modules__[moduleId].call(
  771. module.exports,
  772. module,
  773. module.exports,
  774. __webpack_require__
  775. ),
  776. module.exports
  777. )
  778. }
  779. ;(__webpack_require__.n = module => {
  780. var getter =
  781. module && module.__esModule ? () => module.default : () => module
  782. return __webpack_require__.d(getter, { a: getter }), getter
  783. }),
  784. (__webpack_require__.d = (exports, definition) => {
  785. for (var key in definition)
  786. __webpack_require__.o(definition, key) &&
  787. !__webpack_require__.o(exports, key) &&
  788. Object.defineProperty(exports, key, {
  789. enumerable: !0,
  790. get: definition[key],
  791. })
  792. }),
  793. (__webpack_require__.o = (obj, prop) =>
  794. Object.prototype.hasOwnProperty.call(obj, prop)),
  795. (() => {
  796. "use strict"
  797. const external_log_namespaceObject = log
  798. const lib = __webpack_require__(494).assert,
  799. tapNonNull = x => (lib(null != x), x)
  800. var delay = __webpack_require__(228),
  801. delay_default = __webpack_require__.n(delay)
  802. const getTeaserContainers = node =>
  803. Array.from(
  804. node.querySelectorAll(
  805. ".views-responsive-grid, .node-playlist .field-name-field-videos"
  806. )
  807. ).filter(grid =>
  808. grid.querySelector(
  809. ".node-teaser, .node-sidebar_teaser, .node-wide_teaser"
  810. )
  811. ),
  812. partial_lib = (f, ...headArgs) => (...restArgs) =>
  813. f(...headArgs, ...restArgs),
  814. tapIs = (constructor, x) => (lib(x instanceof constructor), x)
  815. function function_pipe(
  816. a,
  817. ab,
  818. bc,
  819. cd,
  820. de,
  821. ef,
  822. fg,
  823. gh,
  824. hi,
  825. ij,
  826. jk,
  827. kl,
  828. lm,
  829. mn,
  830. no,
  831. op,
  832. pq,
  833. qr,
  834. rs,
  835. st
  836. ) {
  837. switch (arguments.length) {
  838. case 1:
  839. return a
  840. case 2:
  841. return ab(a)
  842. case 3:
  843. return bc(ab(a))
  844. case 4:
  845. return cd(bc(ab(a)))
  846. case 5:
  847. return de(cd(bc(ab(a))))
  848. case 6:
  849. return ef(de(cd(bc(ab(a)))))
  850. case 7:
  851. return fg(ef(de(cd(bc(ab(a))))))
  852. case 8:
  853. return gh(fg(ef(de(cd(bc(ab(a)))))))
  854. case 9:
  855. return hi(gh(fg(ef(de(cd(bc(ab(a))))))))
  856. case 10:
  857. return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))
  858. case 11:
  859. return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))
  860. case 12:
  861. return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))
  862. case 13:
  863. return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))
  864. case 14:
  865. return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))
  866. case 15:
  867. return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))
  868. case 16:
  869. return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  870. case 17:
  871. return pq(
  872. op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  873. )
  874. case 18:
  875. return qr(
  876. pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))
  877. )
  878. case 19:
  879. return rs(
  880. qr(
  881. pq(
  882. op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  883. )
  884. )
  885. )
  886. case 20:
  887. return st(
  888. rs(
  889. qr(
  890. pq(
  891. op(
  892. no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))
  893. )
  894. )
  895. )
  896. )
  897. )
  898. }
  899. }
  900. var isNone = function (fa) {
  901. return "None" === fa._tag
  902. },
  903. none = { _tag: "None" },
  904. some = function (a) {
  905. return { _tag: "Some", value: a }
  906. }
  907. function fromNullable(a) {
  908. return null == a ? none : some(a)
  909. }
  910. var getOrElse = function (onNone) {
  911. return function (ma) {
  912. return isNone(ma) ? onNone() : ma.value
  913. }
  914. }
  915. var map = function (f) {
  916. return function (fa) {
  917. return isNone(fa) ? none : some(f(fa.value))
  918. }
  919. }
  920. var ReadonlyArray_filter = function (predicate) {
  921. return function (fa) {
  922. return fa.filter(predicate)
  923. }
  924. }
  925. var Array_filter = ReadonlyArray_filter
  926. const external_m_namespaceObject = m
  927. var external_m_default = __webpack_require__.n(external_m_namespaceObject)
  928. const external_rxjs_namespaceObject = rxjs,
  929. external_rxjs_operators_namespaceObject = rxjs.operators,
  930. external_Swal_namespaceObject = Swal
  931. var external_Swal_default = __webpack_require__.n(
  932. external_Swal_namespaceObject
  933. )
  934. const forward_to_lib = observer => value => {
  935. observer.next(value)
  936. },
  937. classAttr = classNames => classNames.map(x => `.${x}`).join(""),
  938. conditionPresets = {
  939. "Default Condition":
  940. "(Math.asinh(ratio * 15) / 15 / (private * 1.8 + 1) + Math.log(likes) / 230) / (image + 8)",
  941. Newest: "-index",
  942. Oldest: "index",
  943. "Likes / Views": "ratio",
  944. "Most Liked": "likes",
  945. "Most Viewed": "views",
  946. },
  947. getInputValue = event$ =>
  948. event$.pipe(
  949. (0, external_rxjs_operators_namespaceObject.pluck)("currentTarget"),
  950. (0, external_rxjs_operators_namespaceObject.map)(
  951. partial_lib(tapIs, HTMLInputElement)
  952. ),
  953. (0, external_rxjs_operators_namespaceObject.pluck)("value")
  954. ),
  955. getPageParam = URL_ =>
  956. ((URL_, name) => {
  957. const param = URL_.searchParams.get(name)
  958. return param ? Number.parseInt(param, 10) : 0
  959. })(URL_, "page"),
  960. reloadImage = image => {
  961. const { src } = image
  962. ;(image.src = ""), (image.src = src)
  963. },
  964. removeEmbeddedPage = page => {
  965. ;(page.src = ""), page.remove()
  966. },
  967. getTeaserValue = (info, condition) => {
  968. const sortParamPairs = [
  969. ["index", info.initialIndex],
  970. ["views", info.viewCount],
  971. ["likes", info.likeCount],
  972. [
  973. "ratio",
  974. Math.min(info.likeCount / Math.max(1, info.viewCount), 1),
  975. ],
  976. ["image", info.imageFactor],
  977. ["gallery", info.galleryFactor],
  978. ["private", info.privateFactor],
  979. ]
  980. return new Function(
  981. ...sortParamPairs.map(([name]) => name),
  982. `return (${condition})`
  983. )(...sortParamPairs.map(pair => pair[1]))
  984. },
  985. changeAnchorPageParam = (anchor, value) =>
  986. ((anchor, name, value) => {
  987. const newURL = new URL(anchor.href, window.location.href)
  988. newURL.searchParams.set(name, value), (anchor.href = newURL.href)
  989. })(anchor, "page", value.toString()),
  990. groupPageItems = pageItems => {
  991. const group = document.createElement("li")
  992. pageItems[0].before(group),
  993. (pageItems[0].style.marginLeft = "0"),
  994. pageItems.forEach(item => {
  995. item.classList.replace("pager-item", "pager-current")
  996. })
  997. const groupList = external_m_default()("ul", {
  998. style: {
  999. display: "inline",
  1000. backgroundColor: "hsla(0, 0%, 75%, 50%)",
  1001. },
  1002. oncreate(vnode) {
  1003. vnode.dom.append(...pageItems)
  1004. },
  1005. })
  1006. external_m_default().render(group, groupList)
  1007. },
  1008. adjustPager = ({ container, pageCount }) => {
  1009. const currentPage = getPageParam(new URL(window.location.href)),
  1010. nextPage = currentPage + pageCount
  1011. var predicate
  1012. ;[
  1013. ...[
  1014. () => [
  1015. tapNonNull(container.querySelector(".pager-previous a")),
  1016. Math.max(0, currentPage - pageCount),
  1017. ],
  1018. ].filter(() => currentPage > 0),
  1019. ...(() => {
  1020. const nextPageAnchor = container.querySelector(".pager-next a"),
  1021. lastPageAnchor = container.querySelector(".pager-last a")
  1022. if (lastPageAnchor) {
  1023. const reachedLastPage =
  1024. getPageParam(
  1025. new URL(lastPageAnchor.href, window.location.href)
  1026. ) < nextPage,
  1027. display = reachedLastPage ? "none" : ""
  1028. if (
  1029. ((lastPageAnchor.style.display = display),
  1030. lib(nextPageAnchor),
  1031. (nextPageAnchor.style.display = display),
  1032. !reachedLastPage)
  1033. )
  1034. return [() => [nextPageAnchor, nextPage]]
  1035. } else if (nextPageAnchor)
  1036. return [() => [nextPageAnchor, nextPage]]
  1037. return []
  1038. })(),
  1039. ].forEach(getArgs => changeAnchorPageParam(...getArgs())),
  1040. function_pipe(
  1041. Array.from(container.querySelectorAll(".pager-item a")),
  1042. Array_filter(anchor => {
  1043. const page = getPageParam(
  1044. new URL(anchor.href, window.location.href)
  1045. )
  1046. return page >= currentPage && page < nextPage
  1047. }),
  1048. ((predicate = currentPageAnchors =>
  1049. currentPageAnchors.length > 0),
  1050. function (a) {
  1051. return predicate(a) ? some(a) : none
  1052. }),
  1053. map(anchors => [
  1054. ...Array.from(container.querySelectorAll(".pager-current")),
  1055. ...anchors.map(anchor => tapNonNull(anchor.parentElement)),
  1056. ]),
  1057. map(groupPageItems)
  1058. )
  1059. },
  1060. getBrokenImages = () =>
  1061. getTeaserContainers(document)
  1062. .flatMap(container => Array.from(container.querySelectorAll("img")))
  1063. .filter(img => img.complete && 0 === img.naturalWidth),
  1064. createPreloadPage = (createContainer, parentPageId, url) => {
  1065. const container = createContainer()
  1066. return (
  1067. (container.src = url.toString()),
  1068. (container.style.display = "none"),
  1069. container.classList.add(parentPageId),
  1070. container
  1071. )
  1072. },
  1073. createPreloadUrl = (startURL, page) => {
  1074. const preloadURL = new URL("", startURL)
  1075. return (
  1076. preloadURL.searchParams.set("page", page.toString()), preloadURL
  1077. )
  1078. },
  1079. preloadUrlStream = (startURL, pageCount$) =>
  1080. pageCount$.pipe(
  1081. (0, external_rxjs_operators_namespaceObject.scan)(
  1082. (max, value) => Math.max(max, value),
  1083. 1
  1084. ),
  1085. (0, external_rxjs_operators_namespaceObject.scan)(
  1086. ([, last], current) => [last, current],
  1087. [1, 1]
  1088. ),
  1089. (0,
  1090. external_rxjs_operators_namespaceObject.mergeMap)(
  1091. ([last, current]) =>
  1092. (0, external_rxjs_namespaceObject.from)(
  1093. [...Array(current - last).keys()].map(
  1094. i => getPageParam(startURL) + last + i
  1095. )
  1096. )
  1097. ),
  1098. (0, external_rxjs_operators_namespaceObject.map)(
  1099. partial_lib(createPreloadUrl, startURL)
  1100. )
  1101. ),
  1102. trySortTeasers = condition$ =>
  1103. condition$.pipe(
  1104. (0, external_rxjs_operators_namespaceObject.map)(condition => [
  1105. getTeaserContainers(document),
  1106. condition,
  1107. ]),
  1108. (0, external_rxjs_operators_namespaceObject.mergeMap)(x =>
  1109. (0, external_rxjs_namespaceObject.of)(x).pipe(
  1110. (0, external_rxjs_operators_namespaceObject.tap)(
  1111. ([containers, condition]) =>
  1112. containers.forEach(container =>
  1113. ((container, condition) => {
  1114. const teaserDivs = Array.from(
  1115. container.querySelectorAll(
  1116. ".node-teaser, .node-sidebar_teaser, .node-wide_teaser"
  1117. )
  1118. ),
  1119. sortedTeaserCount = container.dataset
  1120. .sortedTeaserCount
  1121. ? parseInt(container.dataset.sortedTeaserCount, 10)
  1122. : 0
  1123. teaserDivs
  1124. .filter(({ dataset }) => !dataset.initialIndex)
  1125. .forEach(({ dataset }, index) => {
  1126. dataset.initialIndex = (
  1127. sortedTeaserCount + index
  1128. ).toString()
  1129. }),
  1130. (container.dataset.sortedTeaserCount = teaserDivs.length.toString())
  1131. const getNearbyNumber = element => {
  1132. return (
  1133. (str = element.nextSibling.wholeText.replace(
  1134. /,/g,
  1135. ""
  1136. )),
  1137. Number.parseFloat(str) *
  1138. (str.includes("k") ? 1e3 : 1)
  1139. )
  1140. var str
  1141. },
  1142. nearbyNumberOrZero = element =>
  1143. function_pipe(
  1144. fromNullable(element),
  1145. map(getNearbyNumber),
  1146. getOrElse(() => 0)
  1147. ),
  1148. divValuePairs = teaserDivs
  1149. .map(div => ({
  1150. initialIndex: parseInt(
  1151. tapNonNull(div.dataset.initialIndex),
  1152. 10
  1153. ),
  1154. viewCount: nearbyNumberOrZero(
  1155. div.querySelector(".glyphicon-eye-open")
  1156. ),
  1157. likeCount: nearbyNumberOrZero(
  1158. div.querySelector(".glyphicon-heart")
  1159. ),
  1160. imageFactor: div.querySelector(
  1161. ".field-type-image"
  1162. )
  1163. ? 1
  1164. : 0,
  1165. galleryFactor: div.querySelector(
  1166. ".glyphicon-th-large"
  1167. )
  1168. ? 1
  1169. : 0,
  1170. privateFactor: div.querySelector(".private-video")
  1171. ? 1
  1172. : 0,
  1173. }))
  1174. .map((info, index) => [
  1175. teaserDivs[index],
  1176. getTeaserValue(info, condition),
  1177. ])
  1178. divValuePairs.sort(
  1179. (itemA, itemB) => itemB[1] - itemA[1]
  1180. ),
  1181. teaserDivs.forEach(div =>
  1182. div.after(document.createElement("span"))
  1183. ),
  1184. teaserDivs
  1185. .map(div => tapNonNull(div.nextSibling))
  1186. .forEach((anchor, index) =>
  1187. anchor.replaceWith(divValuePairs[index][0])
  1188. )
  1189. })(container, condition)
  1190. )
  1191. ),
  1192. (0, external_rxjs_operators_namespaceObject.catchError)(
  1193. error => (
  1194. external_Swal_default().fire(
  1195. "Sorting Failed",
  1196. `An error accured while sorting: ${error.toString()}`
  1197. ),
  1198. external_log_namespaceObject.error(error),
  1199. external_rxjs_namespaceObject.EMPTY
  1200. )
  1201. )
  1202. )
  1203. ),
  1204. (0,
  1205. external_rxjs_operators_namespaceObject.map)(([containers]) => ({
  1206. containersCount: containers.length,
  1207. }))
  1208. ),
  1209. initParent = async () => {
  1210. if (0 === getTeaserContainers(document).length) return
  1211. const initialCondition = tapNonNull(
  1212. await GM.getValue(
  1213. "sortValue",
  1214. conditionPresets["Default Condition"]
  1215. )
  1216. ),
  1217. pageCount = tapNonNull(await GM.getValue("pageCount", 1)),
  1218. haveMorePages =
  1219. document.querySelector(".pager") &&
  1220. !document.querySelector("#comments"),
  1221. sortComponent = new (class {
  1222. constructor(initialCondition, initialPageCount) {
  1223. ;(this.conditionInputInput$ = new external_rxjs_namespaceObject.Subject()),
  1224. (this.conditionInputChange$ = new external_rxjs_namespaceObject.Subject()),
  1225. (this.conditionInputKeydown$ = new external_rxjs_namespaceObject.Subject()),
  1226. (this.sortButtonClick$ = new external_rxjs_namespaceObject.Subject()),
  1227. (this.presetSelectChange$ = new external_rxjs_namespaceObject.Subject()),
  1228. (this.pageCountInputInput$ = new external_rxjs_namespaceObject.Subject()),
  1229. (this.pageCountInputChange$ = new external_rxjs_namespaceObject.Subject()),
  1230. (this.conditionInputEnterDown$ = this.conditionInputKeydown$.pipe(
  1231. (0, external_rxjs_operators_namespaceObject.filter)(
  1232. e => "Enter" === e.key
  1233. )
  1234. )),
  1235. (this.conditionChange$ = (0,
  1236. external_rxjs_namespaceObject.merge)(
  1237. this.conditionInputEnterDown$,
  1238. this.presetSelectChange$,
  1239. this.conditionInputChange$
  1240. )),
  1241. (this.sort$ = (0, external_rxjs_namespaceObject.merge)(
  1242. this.sortButtonClick$,
  1243. this.conditionInputEnterDown$,
  1244. this.presetSelectChange$
  1245. ).pipe(
  1246. (0, external_rxjs_operators_namespaceObject.map)(
  1247. () => this.state.condition
  1248. )
  1249. )),
  1250. (this.condition$ = this.conditionChange$.pipe(
  1251. (0, external_rxjs_operators_namespaceObject.startWith)(
  1252. void 0
  1253. ),
  1254. (0, external_rxjs_operators_namespaceObject.map)(
  1255. () => this.state.condition
  1256. )
  1257. )),
  1258. (this.pageCount$ = this.pageCountInputChange$.pipe(
  1259. (0, external_rxjs_operators_namespaceObject.startWith)(
  1260. void 0
  1261. ),
  1262. (0, external_rxjs_operators_namespaceObject.map)(
  1263. () => this.state.pageCount
  1264. )
  1265. )),
  1266. (this.state = {
  1267. condition: initialCondition,
  1268. pageCount: initialPageCount,
  1269. loadedPageCount: 0,
  1270. }),
  1271. (0, external_rxjs_namespaceObject.merge)(
  1272. this.conditionInputInput$.pipe(
  1273. getInputValue,
  1274. (0, external_rxjs_operators_namespaceObject.tap)(
  1275. value => {
  1276. this.state.condition = value
  1277. }
  1278. )
  1279. ),
  1280. (0, external_rxjs_namespaceObject.merge)(
  1281. this.conditionChange$,
  1282. this.presetSelectChange$.pipe(
  1283. (0, external_rxjs_operators_namespaceObject.tap)(e => {
  1284. this.state.condition = tapIs(
  1285. HTMLSelectElement,
  1286. e.currentTarget
  1287. ).value
  1288. })
  1289. )
  1290. ).pipe(
  1291. (0, external_rxjs_operators_namespaceObject.map)(
  1292. () => this.state.condition
  1293. ),
  1294. (0, external_rxjs_operators_namespaceObject.tap)(value =>
  1295. GM.setValue("sortValue", value)
  1296. )
  1297. ),
  1298. this.pageCountInputInput$.pipe(
  1299. getInputValue,
  1300. (0, external_rxjs_operators_namespaceObject.map)(value =>
  1301. Number.parseInt(value, 10)
  1302. ),
  1303. (0, external_rxjs_operators_namespaceObject.tap)(
  1304. pageCount => {
  1305. this.state.pageCount = pageCount
  1306. }
  1307. )
  1308. ),
  1309. this.pageCountInputChange$.pipe(
  1310. (0, external_rxjs_operators_namespaceObject.tap)(() =>
  1311. GM.setValue("pageCount", this.state.pageCount)
  1312. )
  1313. )
  1314. ).subscribe()
  1315. }
  1316. view() {
  1317. const commonStyle = { margin: "5px 2px" },
  1318. presetOptions = Object.entries(
  1319. conditionPresets
  1320. ).map(([name, value]) =>
  1321. external_m_default()("option", { value }, name)
  1322. ),
  1323. uiChildren = {
  1324. conditionInput: external_m_default()(
  1325. `input${classAttr(["form-control", "input-sm"])}`,
  1326. {
  1327. size: 60,
  1328. value: this.state.condition,
  1329. style: commonStyle,
  1330. list: "iwara-custom-sort-conditions",
  1331. oninput: forward_to_lib(this.conditionInputInput$),
  1332. onchange: forward_to_lib(this.conditionInputChange$),
  1333. onkeydown: forward_to_lib(this.conditionInputKeydown$),
  1334. }
  1335. ),
  1336. conditionDatalist: external_m_default()(
  1337. "datalist",
  1338. { id: "iwara-custom-sort-conditions" },
  1339. presetOptions
  1340. ),
  1341. presetSelect: external_m_default()(
  1342. `select${classAttr(["btn", "btn-sm", "btn-info"])}`,
  1343. {
  1344. onupdate: vnode => {
  1345. tapIs(HTMLSelectElement, vnode.dom).selectedIndex = 0
  1346. },
  1347. style: { width: "95px", ...commonStyle },
  1348. onchange: forward_to_lib(this.presetSelectChange$),
  1349. },
  1350. [
  1351. external_m_default()(
  1352. "option",
  1353. { hidden: !0 },
  1354. "Presets"
  1355. ),
  1356. ...presetOptions,
  1357. ]
  1358. ),
  1359. sortButton: external_m_default()(
  1360. `button${classAttr(["btn", "btn-sm", "btn-primary"])}`,
  1361. {
  1362. style: commonStyle,
  1363. onclick: forward_to_lib(this.sortButtonClick$),
  1364. },
  1365. "Sort"
  1366. ),
  1367. label1: external_m_default()(
  1368. `label${classAttr(["text-primary"])}`,
  1369. { style: commonStyle },
  1370. "load"
  1371. ),
  1372. pageCountInput: external_m_default()(
  1373. `input${classAttr(["form-control", "input-sm"])}`,
  1374. {
  1375. type: "number",
  1376. value: this.state.pageCount,
  1377. min: 1,
  1378. max: 500,
  1379. step: 1,
  1380. style: { width: "7rem", ...commonStyle },
  1381. oninput: forward_to_lib(this.pageCountInputInput$),
  1382. onchange: forward_to_lib(this.pageCountInputChange$),
  1383. }
  1384. ),
  1385. label2: external_m_default()(
  1386. `label${classAttr(["text-primary"])}`,
  1387. { style: commonStyle },
  1388. "pages. "
  1389. ),
  1390. statusLabel: external_m_default()(
  1391. `label${classAttr(["text-primary"])}`,
  1392. { style: commonStyle },
  1393. this.state.loadedPageCount < this.state.pageCount
  1394. ? `${this.state.loadedPageCount} of ${this.state.pageCount} pages done`
  1395. : "All pages done"
  1396. ),
  1397. }
  1398. return external_m_default()(
  1399. `div${classAttr(["form-inline", "container"])}`,
  1400. { style: { display: "inline-block" } },
  1401. Object.values(uiChildren)
  1402. )
  1403. }
  1404. addLoadedPageCount() {
  1405. ;(this.state.loadedPageCount += 1),
  1406. external_m_default().redraw()
  1407. }
  1408. })(initialCondition, pageCount),
  1409. preloadUrl$ = (haveMorePages
  1410. ? sortComponent.pageCount$
  1411. : (0, external_rxjs_namespaceObject.of)(1)
  1412. ).pipe(
  1413. partial_lib(preloadUrlStream, new URL(window.location.href))
  1414. ),
  1415. channel = new BroadcastChannel("iwara-custom-sort"),
  1416. parentPageId = `t-${performance.now().toString()}`,
  1417. pageLoad$ = (0, external_rxjs_namespaceObject.fromEvent)(
  1418. channel,
  1419. "message"
  1420. ).pipe(
  1421. (0, external_rxjs_operators_namespaceObject.pluck)("data"),
  1422. (0, external_rxjs_operators_namespaceObject.filter)(
  1423. data => data.parentPageId === parentPageId
  1424. )
  1425. ),
  1426. teaserPageLoad$ = pageLoad$.pipe(
  1427. (0, external_rxjs_operators_namespaceObject.filter)(
  1428. message => message.hasTeasers
  1429. )
  1430. ),
  1431. pageFromUrl = new Map(),
  1432. unsortedTeasers$ = teaserPageLoad$.pipe(
  1433. (0, external_rxjs_operators_namespaceObject.mapTo)(void 0),
  1434. (0, external_rxjs_operators_namespaceObject.startWith)(void 0)
  1435. ),
  1436. clonedClass = "iwara-custom-sort-cloned",
  1437. allStreams = {
  1438. adjustPager$: sortComponent.pageCount$.pipe(
  1439. (0, external_rxjs_operators_namespaceObject.mergeMap)(count =>
  1440. (0, external_rxjs_namespaceObject.from)(
  1441. document.querySelectorAll(`.pager:not(.${clonedClass})`)
  1442. ).pipe(
  1443. (0, external_rxjs_operators_namespaceObject.tap)(pager => {
  1444. pager.style.display = "none"
  1445. }),
  1446. (0, external_rxjs_operators_namespaceObject.map)(pager => {
  1447. const clonedPager = tapIs(
  1448. HTMLElement,
  1449. pager.cloneNode(!0)
  1450. )
  1451. return (
  1452. (clonedPager.style.display = ""), [pager, clonedPager]
  1453. )
  1454. }),
  1455. (0, external_rxjs_operators_namespaceObject.tap)(
  1456. ([pager, clonedPager]) => {
  1457. const sibling = pager.previousElementSibling
  1458. sibling && sibling.matches(`.${clonedClass}`)
  1459. ? sibling.replaceWith(clonedPager)
  1460. : pager.before(clonedPager)
  1461. }
  1462. ),
  1463. (0, external_rxjs_operators_namespaceObject.tap)(
  1464. ([, clonedPager]) => {
  1465. clonedPager.classList.add(clonedClass)
  1466. }
  1467. ),
  1468. (0,
  1469. external_rxjs_operators_namespaceObject.map)(
  1470. ([, clonedPager]) => ({
  1471. container: clonedPager,
  1472. pageCount: count,
  1473. })
  1474. )
  1475. )
  1476. ),
  1477. (0, external_rxjs_operators_namespaceObject.tap)(adjustPager)
  1478. ),
  1479. logPageLoad$: pageLoad$.pipe(
  1480. (0, external_rxjs_operators_namespaceObject.tap)(
  1481. external_log_namespaceObject.info
  1482. )
  1483. ),
  1484. reloadBrokenImages$: unsortedTeasers$.pipe(
  1485. (0, external_rxjs_operators_namespaceObject.mergeMap)(() =>
  1486. (0, external_rxjs_namespaceObject.timer)(0, 8e3).pipe(
  1487. (0, external_rxjs_operators_namespaceObject.take)(2)
  1488. )
  1489. ),
  1490. (0, external_rxjs_operators_namespaceObject.auditTime)(6e3),
  1491. (0, external_rxjs_operators_namespaceObject.map)(
  1492. getBrokenImages
  1493. ),
  1494. (0, external_rxjs_operators_namespaceObject.tap)(images =>
  1495. images.forEach(reloadImage)
  1496. ),
  1497. (0, external_rxjs_operators_namespaceObject.map)(
  1498. images => `Reload ${images.length} broken image(s)`
  1499. ),
  1500. (0, external_rxjs_operators_namespaceObject.tap)(
  1501. external_log_namespaceObject.info
  1502. )
  1503. ),
  1504. sortTeasers$: (0, external_rxjs_namespaceObject.merge)(
  1505. unsortedTeasers$.pipe(
  1506. (0, external_rxjs_operators_namespaceObject.withLatestFrom)(
  1507. sortComponent.condition$
  1508. ),
  1509. (0, external_rxjs_operators_namespaceObject.map)(
  1510. ([, condition]) => condition
  1511. ),
  1512. (0, external_rxjs_operators_namespaceObject.tap)(() =>
  1513. sortComponent.addLoadedPageCount()
  1514. )
  1515. ),
  1516. sortComponent.sort$
  1517. ).pipe(
  1518. trySortTeasers,
  1519. (0, external_rxjs_operators_namespaceObject.map)(
  1520. result => `${result.containersCount} containers sorted`
  1521. ),
  1522. (0, external_rxjs_operators_namespaceObject.tap)(
  1523. external_log_namespaceObject.info
  1524. )
  1525. ),
  1526. removeLoadedPage$: pageLoad$.pipe(
  1527. (0, external_rxjs_operators_namespaceObject.map)(({ url }) => ({
  1528. url,
  1529. container: pageFromUrl.get(url),
  1530. })),
  1531. (0, external_rxjs_operators_namespaceObject.tap)(({ url }) =>
  1532. pageFromUrl.delete(url)
  1533. ),
  1534. (0, external_rxjs_operators_namespaceObject.pluck)("container"),
  1535. (0, external_rxjs_operators_namespaceObject.map)(tapNonNull),
  1536. (0, external_rxjs_operators_namespaceObject.tap)(
  1537. removeEmbeddedPage
  1538. )
  1539. ),
  1540. addHiddenPreload$: (0, external_rxjs_namespaceObject.zip)(
  1541. preloadUrl$,
  1542. teaserPageLoad$.pipe(
  1543. (0, external_rxjs_operators_namespaceObject.scan)(
  1544. countDown => (countDown > 0 ? countDown - 1 : countDown),
  1545. 5
  1546. ),
  1547. (0, external_rxjs_operators_namespaceObject.map)(countDown =>
  1548. countDown > 0 ? 2 : 1
  1549. ),
  1550. (0, external_rxjs_operators_namespaceObject.startWith)(2),
  1551. (0,
  1552. external_rxjs_operators_namespaceObject.mergeMap)(
  1553. createPageCount =>
  1554. (0, external_rxjs_namespaceObject.of)(
  1555. ...Array.from({ length: createPageCount }, () => {})
  1556. )
  1557. )
  1558. )
  1559. ).pipe(
  1560. (0, external_rxjs_operators_namespaceObject.map)(([url]) => [
  1561. url,
  1562. () => {
  1563. return (
  1564. (userAgent = window.navigator.userAgent),
  1565. document.createElement(
  1566. userAgent.indexOf("Firefox") > -1 ? "embed" : "iframe"
  1567. )
  1568. )
  1569. var userAgent
  1570. },
  1571. ]),
  1572. (0,
  1573. external_rxjs_operators_namespaceObject.map)(
  1574. ([url, createContainer]) => [
  1575. url.toString(),
  1576. createPreloadPage(createContainer, parentPageId, url),
  1577. ]
  1578. ),
  1579. (0, external_rxjs_operators_namespaceObject.tap)(entry =>
  1580. pageFromUrl.set(...entry)
  1581. ),
  1582. (0,
  1583. external_rxjs_operators_namespaceObject.tap)(([, container]) =>
  1584. document.body.append(container)
  1585. )
  1586. ),
  1587. }
  1588. ;(0, external_rxjs_namespaceObject.merge)(
  1589. ...Object.values(allStreams)
  1590. ).subscribe()
  1591. const sortComponentContainer = document.createElement("div")
  1592. tapNonNull(document.querySelector("#user-links")).after(
  1593. sortComponentContainer
  1594. ),
  1595. external_m_default().mount(sortComponentContainer, sortComponent),
  1596. external_log_namespaceObject.debug(await GM.listValues())
  1597. },
  1598. initialize = async () => {
  1599. const isParent = window === window.parent
  1600. external_log_namespaceObject.debug(
  1601. `${isParent ? "Parent" : "Child"}: ${window.location.href}`
  1602. ),
  1603. await (isParent
  1604. ? initParent()
  1605. : (async () => {
  1606. const teaserContainers = getTeaserContainers(document),
  1607. channel = new BroadcastChannel("iwara-custom-sort"),
  1608. hasTeasers = teaserContainers.length > 0,
  1609. message = {
  1610. url: window.location.href,
  1611. parentPageId: Array.from(
  1612. tapNonNull(window.frameElement).classList
  1613. ).filter(x => x.startsWith("t-"))[0],
  1614. hasTeasers,
  1615. }
  1616. hasTeasers &&
  1617. (await delay_default()(500),
  1618. ((children, parents) => {
  1619. for (
  1620. let i = 0, j = 0;
  1621. i < parents.length && j < children.length;
  1622. i += 1
  1623. ) {
  1624. const parent = parents[i],
  1625. child = children[j]
  1626. parent.className === child.className &&
  1627. ((child.className = ""),
  1628. parent.append(child),
  1629. (j += 1))
  1630. }
  1631. })(
  1632. teaserContainers,
  1633. getTeaserContainers(window.parent.document)
  1634. )),
  1635. channel.postMessage(message)
  1636. })())
  1637. }
  1638. ;(async () => {
  1639. external_log_namespaceObject.setLevel("debug")
  1640. try {
  1641. await initialize()
  1642. } catch (error) {
  1643. external_log_namespaceObject.error(error)
  1644. }
  1645. })()
  1646. })()
  1647. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址