pervert-monkey 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -417,12 +417,17 @@ declare type ThumbDataSelectorsRaw = Record<string, string | Pick<ThumbDataSelec
417
417
 
418
418
  export declare class ThumbImgParser {
419
419
  selector?: string | string[] | ((img: HTMLImageElement) => string);
420
- shouldDelete?: 'auto' | string;
420
+ remove?: 'auto' | string;
421
421
  strategy: 'default' | 'auto';
422
- static create(options?: Partial<Pick<ThumbImgParser, 'selector' | 'shouldDelete' | 'strategy' | 'getImgData'>>): ThumbImgParser & Partial<Pick<ThumbImgParser, "selector" | "strategy" | "shouldDelete" | "getImgData">>;
422
+ static create(options?: Partial<Pick<ThumbImgParser, 'selector' | 'remove' | 'strategy' | 'getImgData'>>): ThumbImgParser & Partial<Pick<ThumbImgParser, "selector" | "strategy" | "remove" | "getImgData">>;
423
+ private removeAttrs;
424
+ private getImgSrc;
423
425
  getImgData(thumb: HTMLElement): {
424
- img?: HTMLImageElement;
425
- imgSrc?: string;
426
+ img?: undefined;
427
+ imgSrc?: undefined;
428
+ } | {
429
+ img: HTMLImageElement;
430
+ imgSrc: string;
426
431
  };
427
432
  }
428
433
 
@@ -372,20 +372,24 @@ class Observer {
372
372
  this.observer.disconnect();
373
373
  }
374
374
  static observeWhile(target, callback, throttleTime) {
375
- const observer_ = new Observer(async (target2) => {
375
+ const observer = new Observer(async (target2) => {
376
376
  const condition = await callback();
377
- if (condition) observer_.throttle(target2, throttleTime);
377
+ if (condition) {
378
+ observer.throttle(target2, throttleTime);
379
+ } else {
380
+ observer.dispose();
381
+ }
378
382
  });
379
- observer_.observe(target);
380
- return observer_;
383
+ observer.observe(target);
384
+ return observer;
381
385
  }
382
386
  }
383
387
  function formatTimeToHHMMSS(timeStr) {
384
388
  var _a3, _b2, _c2;
385
389
  const pad = (num) => num.toString().padStart(2, "0");
386
390
  const h = ((_a3 = timeStr.match(/(\d+)\s*h/)) == null ? void 0 : _a3[1]) || "0";
387
- const m = ((_b2 = timeStr.match(/(\d+)\s*mi?n/)) == null ? void 0 : _b2[1]) || "0";
388
- const s = ((_c2 = timeStr.match(/(\d+)\s*sec/)) == null ? void 0 : _c2[1]) || "0";
391
+ const m = ((_b2 = timeStr.match(/(\d+)\s*mi?n?/)) == null ? void 0 : _b2[1]) || "0";
392
+ const s = ((_c2 = timeStr.match(/(\d+)\s*se?c?/)) == null ? void 0 : _c2[1]) || "0";
389
393
  return `${pad(+h)}:${pad(+m)}:${pad(+s)}`;
390
394
  }
391
395
  function timeToSeconds(timeStr) {
@@ -435,11 +439,7 @@ const _DataFilter = class _DataFilter {
435
439
  applyCSSFilters(wrapper) {
436
440
  this.filters.forEach((_2, name) => {
437
441
  const cssRule = `.filter-${name} { display: none !important; }`;
438
- if (wrapper) {
439
- GM_addStyle(wrapper(cssRule));
440
- } else {
441
- GM_addStyle(cssRule);
442
- }
442
+ GM_addStyle(wrapper ? wrapper(cssRule) : cssRule);
443
443
  });
444
444
  }
445
445
  registerFilters(customFilters) {
@@ -1282,14 +1282,11 @@ class InfiniteScroller {
1282
1282
  __publicField(this, "subject", new Subject());
1283
1283
  __publicField(this, "generatorConsumer", async () => {
1284
1284
  if (!this.enabled) return false;
1285
- const {
1286
- value: { url, offset },
1287
- done
1288
- } = await this.paginationGenerator.next();
1289
- if (!done && url) {
1290
- await this.doScroll(url, offset);
1291
- }
1292
- return !done;
1285
+ const { value, done } = await this.paginationGenerator.next();
1286
+ if (done) return false;
1287
+ const { url, offset } = value;
1288
+ await this.doScroll(url, offset);
1289
+ return true;
1293
1290
  });
1294
1291
  this.rules = options.rules;
1295
1292
  this.paginationOffset = this.rules.paginationStrategy.getPaginationOffset();
@@ -1317,7 +1314,8 @@ class InfiniteScroller {
1317
1314
  const autoScrollWrapper = async () => {
1318
1315
  if (this.rules.store.state.autoScroll) {
1319
1316
  await wait(this.rules.store.state.delay);
1320
- await this.generatorConsumer();
1317
+ const res = await this.generatorConsumer();
1318
+ if (!res) return;
1321
1319
  await autoScrollWrapper();
1322
1320
  }
1323
1321
  };
@@ -2379,7 +2377,11 @@ class ThumbDataParser {
2379
2377
  __publicField(this, "thumbDataSelectors", []);
2380
2378
  __publicField(this, "defaultThumbDataSelectors", [
2381
2379
  { name: "title", type: "string", selector: "[class *= title],[title]" },
2382
- { name: "uploader", type: "string", selector: "[class *= uploader], [class *= user], [class *= name]" },
2380
+ {
2381
+ name: "uploader",
2382
+ type: "string",
2383
+ selector: "[class *= uploader], [class *= user], [class *= name]"
2384
+ },
2383
2385
  { name: "duration", type: "duration", selector: "[class *= duration]" }
2384
2386
  ]);
2385
2387
  this.strategy = strategy;
@@ -2434,9 +2436,9 @@ class ThumbDataParser {
2434
2436
  if (this.strategy === "auto-select") {
2435
2437
  this.thumbDataSelectors = this.defaultThumbDataSelectors;
2436
2438
  }
2437
- const thumbData = Object.fromEntries(this.thumbDataSelectors.map(
2438
- (s) => [s.name, this.getThumbDataWith(thumb, s)]
2439
- ));
2439
+ const thumbData = Object.fromEntries(
2440
+ this.thumbDataSelectors.map((s) => [s.name, this.getThumbDataWith(thumb, s)])
2441
+ );
2440
2442
  if (this.stringsMeltInTitle) {
2441
2443
  Object.entries(thumbData).forEach(([k2, v2]) => {
2442
2444
  if (typeof v2 === "string" && k2 !== "title") {
@@ -2452,50 +2454,47 @@ class ThumbDataParser {
2452
2454
  class ThumbImgParser {
2453
2455
  constructor() {
2454
2456
  __publicField(this, "selector");
2455
- __publicField(this, "shouldDelete");
2457
+ __publicField(this, "remove");
2456
2458
  __publicField(this, "strategy", "default");
2457
2459
  }
2458
2460
  static create(options = {}) {
2459
2461
  return Object.assign(new ThumbImgParser(), options);
2460
2462
  }
2461
- getImgData(thumb) {
2462
- const result = {};
2463
- if (this.strategy === "auto") {
2464
- const img = thumb.querySelector("img");
2465
- if (!img) return {};
2466
- result.img = img;
2467
- if (typeof this.selector === "function") {
2468
- result.imgSrc = this.selector(img);
2463
+ removeAttrs(img) {
2464
+ if (!this.remove) return;
2465
+ if (this.remove === "auto") {
2466
+ removeClassesAndDataAttributes(img, "lazy");
2467
+ } else {
2468
+ if (this.remove.startsWith(".")) {
2469
+ img.classList.remove(this.remove.slice(1));
2469
2470
  } else {
2470
- const possibleAttrs = this.selector ? [this.selector].flat() : ["data-src", "src"];
2471
- for (const attr of possibleAttrs) {
2472
- const imgSrc = img.getAttribute(attr);
2473
- if (imgSrc) {
2474
- result.imgSrc = imgSrc;
2475
- img.removeAttribute(attr);
2476
- break;
2477
- }
2478
- }
2471
+ img.removeAttribute(this.remove);
2479
2472
  }
2480
- if (this.shouldDelete) {
2481
- if (this.shouldDelete === "auto") {
2482
- removeClassesAndDataAttributes(img, "lazy");
2483
- } else {
2484
- if (this.shouldDelete.startsWith(".")) {
2485
- img.classList.remove(this.shouldDelete.slice(1));
2486
- } else {
2487
- img.removeAttribute(this.shouldDelete);
2488
- }
2489
- }
2490
- if (img.src.includes("data:image")) {
2491
- result.img.src = "";
2492
- }
2493
- if (img.complete && img.naturalWidth > 0) {
2494
- return {};
2495
- }
2473
+ }
2474
+ }
2475
+ getImgSrc(img) {
2476
+ const possibleAttrs = this.selector ? [this.selector].flat() : ["data-src", "src"];
2477
+ for (const attr of possibleAttrs) {
2478
+ const imgSrc = img.getAttribute(attr);
2479
+ if (imgSrc) {
2480
+ return imgSrc;
2496
2481
  }
2497
2482
  }
2498
- return result;
2483
+ return "";
2484
+ }
2485
+ getImgData(thumb) {
2486
+ if (this.strategy === "default" && !this.selector) return {};
2487
+ const img = thumb.querySelector("img");
2488
+ if (!img) return {};
2489
+ const imgSrc = typeof this.selector === "function" ? this.selector(img) : this.getImgSrc(img);
2490
+ this.removeAttrs(img);
2491
+ if (img.src.includes("data:image")) {
2492
+ img.src = "";
2493
+ }
2494
+ if (img.complete && img.naturalWidth > 0) {
2495
+ return {};
2496
+ }
2497
+ return { img, imgSrc };
2499
2498
  }
2500
2499
  }
2501
2500
  class ThumbsParser {