pervert-monkey 1.0.18 → 1.0.19

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.
Files changed (53) hide show
  1. package/dist/core/pervertmonkey.core.es.d.ts +8 -11
  2. package/dist/core/pervertmonkey.core.es.js +31 -35
  3. package/dist/core/pervertmonkey.core.es.js.map +1 -1
  4. package/dist/core/pervertmonkey.core.umd.js +31 -35
  5. package/dist/core/pervertmonkey.core.umd.js.map +1 -1
  6. package/dist/test/test.user.js +10301 -0
  7. package/dist/userscripts/3hentai.user.js +2 -2
  8. package/dist/userscripts/camgirlfinder.user.js +2 -2
  9. package/dist/userscripts/camwhores.user.js +2 -2
  10. package/dist/userscripts/e-hentai.user.js +2 -2
  11. package/dist/userscripts/ebalka.user.js +2 -2
  12. package/dist/userscripts/eporner.user.js +2 -2
  13. package/dist/userscripts/erome.user.js +2 -2
  14. package/dist/userscripts/eroprofile.user.js +2 -2
  15. package/dist/userscripts/javhdporn.user.js +2 -2
  16. package/dist/userscripts/missav.user.js +2 -2
  17. package/dist/userscripts/motherless.user.js +2 -2
  18. package/dist/userscripts/namethatporn.user.js +2 -2
  19. package/dist/userscripts/nhentai.user.js +2 -2
  20. package/dist/userscripts/obmenvsem.user.js +3 -3
  21. package/dist/userscripts/pornhub.user.js +2 -2
  22. package/dist/userscripts/spankbang.user.js +2 -2
  23. package/dist/userscripts/thisvid.user.js +33 -27
  24. package/dist/userscripts/xhamster.user.js +3 -3
  25. package/dist/userscripts/xvideos.user.js +3 -3
  26. package/package.json +4 -4
  27. package/src/core/data-handler/data-filter.ts +4 -4
  28. package/src/core/infinite-scroll/index.ts +2 -9
  29. package/src/core/parsers/thumb-data-parser.ts +4 -3
  30. package/src/core/parsers/thumbs-parser.ts +9 -10
  31. package/src/core/rules/index.ts +6 -7
  32. package/src/userscripts/index.ts +1 -1
  33. package/src/userscripts/scripts/3hentai.ts +1 -1
  34. package/src/userscripts/scripts/camgirlfinder.ts +1 -1
  35. package/src/userscripts/scripts/camwhores.ts +1 -1
  36. package/src/userscripts/scripts/e-hentai.ts +1 -1
  37. package/src/userscripts/scripts/ebalka.ts +1 -1
  38. package/src/userscripts/scripts/eporner.ts +1 -1
  39. package/src/userscripts/scripts/erome.ts +1 -1
  40. package/src/userscripts/scripts/eroprofile.ts +1 -1
  41. package/src/userscripts/scripts/javhdporn.ts +1 -1
  42. package/src/userscripts/scripts/missav.ts +1 -1
  43. package/src/userscripts/scripts/motherless.ts +1 -1
  44. package/src/userscripts/scripts/namethatporn.ts +1 -1
  45. package/src/userscripts/scripts/nhentai.ts +1 -2
  46. package/src/userscripts/scripts/obmenvsem.ts +2 -2
  47. package/src/userscripts/scripts/pornhub.ts +1 -1
  48. package/src/userscripts/scripts/spankbang.ts +1 -1
  49. package/src/userscripts/scripts/thisvid.ts +43 -35
  50. package/src/userscripts/scripts/xhamster.ts +2 -2
  51. package/src/userscripts/scripts/xvideos.ts +2 -2
  52. package/src/utils/dom/index.ts +14 -10
  53. package/src/utils/parsers/index.ts +1 -1
@@ -28,7 +28,7 @@ export declare type DataElement = {
28
28
  export declare class DataFilter {
29
29
  private rules;
30
30
  filters: Map<string, () => DataFilterFnRendered>;
31
- filterMapping: Record<string, string>;
31
+ filterDepsMapping: Record<string, string>;
32
32
  constructor(rules: Rules);
33
33
  static isFiltered(e: HTMLElement): boolean;
34
34
  createCssFilters(wrapper?: (cssRule: string) => string): void;
@@ -223,8 +223,6 @@ export declare function fetchWith<T extends JSON | string | HTMLElement>(input:
223
223
 
224
224
  export declare function findNextSibling<T extends Element = HTMLElement>(e: T): Element | null;
225
225
 
226
- export declare function findSelfOrChild<T extends HTMLElement>(element: T, selector: string): T | null;
227
-
228
226
  /**
229
227
  * Converts a duration string (e.g., "1h 22min 3sec") to HH:MM:SS format.
230
228
  * @param timeStr - The duration string to format.
@@ -237,12 +235,11 @@ declare type GeneratorResult = {
237
235
  offset: number;
238
236
  };
239
237
 
240
- export declare function getCommonParents(elements: HTMLCollection | HTMLElement[]): HTMLElement[];
238
+ export declare function getCommonParents<T extends HTMLElement>(elements: Iterable<T>): HTMLElement[];
241
239
 
242
240
  export declare function getPaginationStrategy(options: Partial<PaginationStrategy>): PaginationStrategy;
243
241
 
244
242
  export declare class InfiniteScroller {
245
- enabled: boolean;
246
243
  paginationOffset: number;
247
244
  rules: Rules;
248
245
  private observer?;
@@ -381,7 +378,7 @@ export declare function parseHtml(html: string): HTMLElement;
381
378
 
382
379
  export declare function parseIntegerOr(n: string | number, or: number): number;
383
380
 
384
- export declare function parseNumberWithLetter(str: string): number;
381
+ export declare function parseNumericAbbreviation(str: string): number;
385
382
 
386
383
  export declare function parseUrl(s: HTMLAnchorElement | Location | URL | string): URL;
387
384
 
@@ -391,6 +388,8 @@ export declare function querySelectorLast<T extends Element = HTMLElement>(root:
391
388
 
392
389
  export declare function querySelectorLastNumber(selector: string, e?: ParentNode): number;
393
390
 
391
+ export declare function querySelectorOrSelf<T extends Element = HTMLElement>(element: T, selector: string): T | null;
392
+
394
393
  export declare function querySelectorText(e: ParentNode, selector?: string): string;
395
394
 
396
395
  export declare function range(size: number, start?: number, step?: number): number[];
@@ -418,7 +417,7 @@ export declare class Rules {
418
417
  containerSelectorLast?: string;
419
418
  get container(): HTMLElement;
420
419
  intersectionObservableSelector?: string;
421
- get intersectionObservable(): "" | Element | null | undefined;
420
+ get intersectionObservable(): HTMLElement | null | undefined;
422
421
  get observable(): HTMLElement;
423
422
  paginationStrategyOptions: Partial<PaginationStrategy>;
424
423
  paginationStrategy: PaginationStrategy;
@@ -501,13 +500,11 @@ export declare class ThumbImgParser {
501
500
  }
502
501
 
503
502
  export declare class ThumbsParser {
504
- containerSelector: string;
505
503
  selector: string;
506
504
  strategy: 'default' | 'auto';
507
505
  transform?: (thumb: HTMLElement) => void;
508
- static create(options: Partial<Pick<ThumbsParser, "selector" | "strategy" | "transform">> | undefined, containerSelector: string): ThumbsParser & Partial<Pick<ThumbsParser, "selector" | "strategy" | "transform">>;
509
- constructor(containerSelector: string);
510
- getThumbs(html: HTMLElement): HTMLElement[];
506
+ static create(options?: Partial<Pick<ThumbsParser, 'selector' | 'strategy' | 'transform'>>): ThumbsParser & Partial<Pick<ThumbsParser, "selector" | "strategy" | "transform">>;
507
+ getThumbs(container: HTMLElement): HTMLElement[];
511
508
  }
512
509
 
513
510
  export declare class Tick {
@@ -172,15 +172,19 @@ function watchDomChangesWithThrottle(element, callback, throttle = 1e3, times =
172
172
  observer.observe(element, options);
173
173
  return observer;
174
174
  }
175
- function findSelfOrChild(element, selector) {
176
- if (element.matches(selector)) {
175
+ function querySelectorOrSelf(element, selector) {
176
+ var _a3;
177
+ if ((_a3 = element.matches) == null ? void 0 : _a3.call(element, selector)) {
177
178
  return element;
178
179
  }
179
180
  return element.querySelector(selector);
180
181
  }
181
182
  function querySelectorLast(root = document, selector) {
182
183
  const nodes = root.querySelectorAll(selector);
183
- return nodes.length > 0 ? nodes[nodes.length - 1] : void 0;
184
+ if (nodes.length < 1) {
185
+ return querySelectorOrSelf(root, selector) || void 0;
186
+ }
187
+ return nodes[nodes.length - 1];
184
188
  }
185
189
  function querySelectorLastNumber(selector, e = document) {
186
190
  var _a3;
@@ -190,7 +194,7 @@ function querySelectorLastNumber(selector, e = document) {
190
194
  function querySelectorText(e, selector) {
191
195
  var _a3;
192
196
  if (typeof selector !== "string") return "";
193
- const text = ((_a3 = e.querySelector(selector)) == null ? void 0 : _a3.innerText) || "";
197
+ const text = ((_a3 = querySelectorOrSelf(e, selector)) == null ? void 0 : _a3.innerText) || "";
194
198
  return sanitizeStr(text);
195
199
  }
196
200
  function parseHtml(html) {
@@ -226,8 +230,7 @@ function removeClassesAndDataAttributes(element, keyword) {
226
230
  });
227
231
  }
228
232
  function getCommonParents(elements) {
229
- const parents = Array.from(elements).map((e) => e.parentElement).filter((parent) => parent !== null);
230
- return [...new Set(parents)];
233
+ return Map.groupBy(elements, (e) => e.parentElement).keys().filter((e) => e !== null).toArray();
231
234
  }
232
235
  function findNextSibling(e) {
233
236
  if (e.nextElementSibling) return e.nextElementSibling;
@@ -437,7 +440,7 @@ function parseIntegerOr(n, or2) {
437
440
  const num = Number(n);
438
441
  return Number.isSafeInteger(num) ? num : or2;
439
442
  }
440
- function parseNumberWithLetter(str) {
443
+ function parseNumericAbbreviation(str) {
441
444
  var _a3;
442
445
  const multipliers = { k: 1e3, m: 1e6 };
443
446
  const match = str.trim().match(/([\d., ]+)(\w)?/);
@@ -552,7 +555,7 @@ const defaultDataFilterFns = {
552
555
  class DataFilter {
553
556
  constructor(rules) {
554
557
  __publicField(this, "filters", /* @__PURE__ */ new Map());
555
- __publicField(this, "filterMapping", {});
558
+ __publicField(this, "filterDepsMapping", {});
556
559
  __publicField(this, "customDataFilterFns", {});
557
560
  this.rules = rules;
558
561
  this.registerFilters(rules.customDataFilterFns);
@@ -583,12 +586,12 @@ class DataFilter {
583
586
  );
584
587
  dataFilterFn.deps.push(customSelectorName);
585
588
  dataFilterFn.deps.forEach((name) => {
586
- Object.assign(this.filterMapping, { [name]: customSelectorName });
589
+ Object.assign(this.filterDepsMapping, { [name]: customSelectorName });
587
590
  });
588
591
  this.filters.set(customSelectorName, dataFilterFn.renderFn(this.rules.store.state));
589
592
  }
590
593
  selectFilters(filters) {
591
- const selectedFilters = Object.keys(filters).filter((k2) => k2 in this.filterMapping).map((k2) => this.filterMapping[k2]).map((k2) => this.filters.get(k2));
594
+ const selectedFilters = Object.keys(filters).filter((k2) => k2 in this.filterDepsMapping).map((k2) => this.filterDepsMapping[k2]).map((k2) => this.filters.get(k2));
592
595
  return selectedFilters;
593
596
  }
594
597
  }
@@ -1954,14 +1957,13 @@ function takeUntil(notifier) {
1954
1957
  }
1955
1958
  class InfiniteScroller {
1956
1959
  constructor(options) {
1957
- __publicField(this, "enabled", true);
1958
1960
  __publicField(this, "paginationOffset", 1);
1959
1961
  __publicField(this, "rules");
1960
1962
  __publicField(this, "observer");
1961
1963
  __publicField(this, "paginationGenerator");
1962
1964
  __publicField(this, "subject", new Subject());
1963
1965
  __publicField(this, "generatorConsumer", async () => {
1964
- if (!this.enabled) return false;
1966
+ if (!this.rules.store.state.infiniteScrollEnabled) return true;
1965
1967
  const { value, done } = await this.paginationGenerator.next();
1966
1968
  if (done) return false;
1967
1969
  const { url, offset } = value;
@@ -2027,9 +2029,8 @@ class InfiniteScroller {
2027
2029
  }
2028
2030
  }
2029
2031
  static create(rules) {
2030
- const enabled = rules.store.state.infiniteScrollEnabled;
2031
2032
  rules.store.state.$paginationLast = rules.paginationStrategy.getPaginationLast();
2032
- const infiniteScroller = new InfiniteScroller({ enabled, rules });
2033
+ const infiniteScroller = new InfiniteScroller({ rules });
2033
2034
  rules.store.state.$paginationOffset = infiniteScroller.paginationOffset;
2034
2035
  infiniteScroller.subject.subscribe((x2) => {
2035
2036
  if (x2.type === "scroll") {
@@ -2040,9 +2041,6 @@ class InfiniteScroller {
2040
2041
  });
2041
2042
  }
2042
2043
  });
2043
- rules.store.stateSubject.subscribe(() => {
2044
- infiniteScroller.enabled = rules.store.state.infiniteScrollEnabled;
2045
- });
2046
2044
  return infiniteScroller;
2047
2045
  }
2048
2046
  }
@@ -3101,7 +3099,7 @@ class ThumbDataParser {
3101
3099
  getThumbDataWith(thumb, { type, selector }) {
3102
3100
  var _a3;
3103
3101
  if (type === "boolean") {
3104
- return !!thumb.querySelector(selector);
3102
+ return !!querySelectorOrSelf(thumb, selector);
3105
3103
  }
3106
3104
  if (type === "string") {
3107
3105
  return sanitizeStr(((_a3 = querySelectorLast(thumb, selector)) == null ? void 0 : _a3.innerText) || "");
@@ -3111,7 +3109,7 @@ class ThumbDataParser {
3111
3109
  }
3112
3110
  if (type === "float") {
3113
3111
  const value = querySelectorText(thumb, selector);
3114
- return parseNumberWithLetter(value);
3112
+ return parseNumericAbbreviation(value);
3115
3113
  }
3116
3114
  return Number.parseInt(querySelectorText(thumb, selector));
3117
3115
  }
@@ -3180,24 +3178,21 @@ class ThumbImgParser {
3180
3178
  }
3181
3179
  }
3182
3180
  class ThumbsParser {
3183
- constructor(containerSelector) {
3181
+ constructor() {
3184
3182
  __publicField(this, "selector", ".thumb");
3185
3183
  __publicField(this, "strategy", "default");
3186
3184
  __publicField(this, "transform");
3187
- this.containerSelector = containerSelector;
3188
3185
  }
3189
- static create(options = {}, containerSelector) {
3190
- return Object.assign(new ThumbsParser(containerSelector), options);
3186
+ static create(options = {}) {
3187
+ return Object.assign(new ThumbsParser(), options);
3191
3188
  }
3192
- getThumbs(html) {
3193
- if (!html) return [];
3194
- let thumbs;
3189
+ getThumbs(container) {
3190
+ if (!container) return [];
3195
3191
  if (this.strategy === "auto") {
3196
3192
  if (typeof this.selector !== "string") return [];
3197
- const container = html.querySelector(this.containerSelector);
3198
- thumbs = [...(container == null ? void 0 : container.children) || []];
3193
+ return [...(container == null ? void 0 : container.children) || []];
3199
3194
  }
3200
- thumbs = Array.from(html.querySelectorAll(this.selector));
3195
+ const thumbs = Array.from(container.querySelectorAll(this.selector));
3201
3196
  if (typeof this.transform === "function") {
3202
3197
  thumbs.forEach(this.transform);
3203
3198
  }
@@ -9897,7 +9892,7 @@ class Rules {
9897
9892
  Object.assign(this, options);
9898
9893
  this.thumbDataParser = ThumbDataParser.create(this.thumb);
9899
9894
  this.thumbImgParser = ThumbImgParser.create(this.thumbImg);
9900
- this.thumbsParser = ThumbsParser.create(this.thumbs, this.containerSelector);
9895
+ this.thumbsParser = ThumbsParser.create(this.thumbs);
9901
9896
  this.paginationStrategy = getPaginationStrategy(this.paginationStrategyOptions);
9902
9897
  this.store = this.createStore();
9903
9898
  this.gui = this.createGui();
@@ -9908,15 +9903,16 @@ class Rules {
9908
9903
  }
9909
9904
  get container() {
9910
9905
  if (typeof this.containerSelectorLast === "string") {
9911
- return querySelectorLast(document, this.containerSelectorLast);
9906
+ return querySelectorLast(document.body, this.containerSelectorLast);
9912
9907
  }
9913
9908
  if (typeof this.containerSelector === "string") {
9914
- return document.querySelector(this.containerSelector);
9909
+ return querySelectorOrSelf(document.body, this.containerSelector);
9915
9910
  }
9916
9911
  return this.containerSelector();
9917
9912
  }
9918
9913
  get intersectionObservable() {
9919
- return this.intersectionObservableSelector && document.querySelector(this.intersectionObservableSelector);
9914
+ if (!this.intersectionObservableSelector) return void 0;
9915
+ return document.querySelector(this.intersectionObservableSelector);
9920
9916
  }
9921
9917
  get observable() {
9922
9918
  return this.intersectionObservable || this.paginationStrategy.getPaginationElement();
@@ -10022,7 +10018,6 @@ export {
10022
10018
  fetchText,
10023
10019
  fetchWith,
10024
10020
  findNextSibling,
10025
- findSelfOrChild,
10026
10021
  formatTimeToHHMMSS,
10027
10022
  getCommonParents,
10028
10023
  getPaginationStrategy,
@@ -10034,10 +10029,11 @@ export {
10034
10029
  parseDataParams,
10035
10030
  parseHtml,
10036
10031
  parseIntegerOr,
10037
- parseNumberWithLetter,
10032
+ parseNumericAbbreviation,
10038
10033
  parseUrl,
10039
10034
  querySelectorLast,
10040
10035
  querySelectorLastNumber,
10036
+ querySelectorOrSelf,
10041
10037
  querySelectorText,
10042
10038
  range,
10043
10039
  removeClassesAndDataAttributes,