pervert-monkey 1.0.25 → 1.0.26

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 (58) hide show
  1. package/README.md +5 -2
  2. package/dist/core/pervertmonkey.core.es.d.ts +2 -541
  3. package/dist/core/pervertmonkey.core.es.js +8001 -9281
  4. package/dist/core/pervertmonkey.core.es.js.map +1 -1
  5. package/dist/core/pervertmonkey.core.umd.js +8829 -10051
  6. package/dist/core/pervertmonkey.core.umd.js.map +1 -1
  7. package/dist/userscripts/3hentai.user.js +40 -46
  8. package/dist/userscripts/camgirlfinder.user.js +56 -49
  9. package/dist/userscripts/camwhores.user.js +286 -343
  10. package/dist/userscripts/e-hentai.user.js +54 -57
  11. package/dist/userscripts/ebalka.user.js +52 -55
  12. package/dist/userscripts/eporner.user.js +76 -68
  13. package/dist/userscripts/erome.user.js +79 -84
  14. package/dist/userscripts/eroprofile.user.js +28 -29
  15. package/dist/userscripts/javhdporn.user.js +28 -22
  16. package/dist/userscripts/missav.user.js +22 -23
  17. package/dist/userscripts/motherless.user.js +141 -152
  18. package/dist/userscripts/namethatporn.user.js +49 -58
  19. package/dist/userscripts/nhentai.user.js +104 -99
  20. package/dist/userscripts/obmenvsem.user.js +61 -69
  21. package/dist/userscripts/pornhub.user.js +50 -47
  22. package/dist/userscripts/simpcity.user.js +26 -23
  23. package/dist/userscripts/socialmediagirls.user.js +26 -22
  24. package/dist/userscripts/spankbang.user.js +62 -44
  25. package/dist/userscripts/thisvid.user.js +1269 -1366
  26. package/dist/userscripts/xhamster.user.js +119 -132
  27. package/dist/userscripts/xvideos.user.js +115 -91
  28. package/package.json +10 -6
  29. package/src/core/data-handler/data-filter.ts +4 -3
  30. package/src/core/parsers/pagination-parser/index.ts +0 -4
  31. package/src/core/parsers/pagination-parser/pagination-strategies/PaginationStrategyPathnameParams.ts +36 -1
  32. package/src/userscripts/index.ts +1 -1
  33. package/src/userscripts/meta.json +1 -1
  34. package/src/userscripts/scripts/3hentai.ts +1 -1
  35. package/src/userscripts/scripts/camgirlfinder.ts +1 -1
  36. package/src/userscripts/scripts/camwhores.ts +2 -2
  37. package/src/userscripts/scripts/e-hentai.ts +1 -1
  38. package/src/userscripts/scripts/ebalka.ts +1 -1
  39. package/src/userscripts/scripts/eporner.ts +41 -15
  40. package/src/userscripts/scripts/erome.ts +1 -1
  41. package/src/userscripts/scripts/eroprofile.ts +6 -6
  42. package/src/userscripts/scripts/javhdporn.ts +1 -1
  43. package/src/userscripts/scripts/missav.ts +1 -1
  44. package/src/userscripts/scripts/motherless.ts +28 -19
  45. package/src/userscripts/scripts/namethatporn.ts +1 -1
  46. package/src/userscripts/scripts/nhentai.ts +1 -1
  47. package/src/userscripts/scripts/obmenvsem.ts +1 -1
  48. package/src/userscripts/scripts/pornhub.ts +1 -1
  49. package/src/userscripts/scripts/simpcity.ts +1 -1
  50. package/src/userscripts/scripts/{socialmediagirls copy.ts → socialmediagirls.ts} +1 -1
  51. package/src/userscripts/scripts/spankbang.ts +20 -4
  52. package/src/userscripts/scripts/thisvid.ts +8 -21
  53. package/src/userscripts/scripts/xhamster.ts +11 -3
  54. package/src/userscripts/scripts/xvideos.ts +26 -7
  55. package/src/utils/fetch/index.ts +2 -0
  56. package/src/utils/objects/memoize.ts +1 -9
  57. package/dist/test/test.user.js +0 -10301
  58. package/dist/userscripts/socialmediagirls copy.user.js +0 -41
@@ -1,367 +1,310 @@
1
1
  // ==UserScript==
2
2
  // @name CamWhores PervertMonkey
3
3
  // @namespace pervertmonkey
4
- // @version 3.0.22
4
+ // @version 3.0.24
5
5
  // @author violent-orangutan
6
6
  // @description Infinite scroll [optional]. Filter by Title, Duration and Private/Public. Sort by Duration and Views. Mass friend request button. Download button
7
7
  // @license MIT
8
8
  // @icon https://www.google.com/s2/favicons?sz=64&domain=camwhores.tv
9
9
  // @homepage https://github.com/smartacephale/sleazy-fork#readme
10
10
  // @homepageURL https://sleazyfork.org/en/users/1253342-smartacephale
11
- // @source https://github.com/smartacephale
11
+ // @source https://github.com/smartacephale/sleazy-fork
12
12
  // @supportURL https://github.com/smartacephale/sleazy-fork/issues
13
- // @match https://*.camwhores.tv
13
+ // @match https://*.camwhores.tv/*
14
14
  // @match https://*.camwhores.*/*
15
15
  // @exclude https://*.camwhores.tv/*mode=async*
16
- // @require https://cdn.jsdelivr.net/npm/pervert-monkey@1.0.25/dist/core/pervertmonkey.core.umd.js
17
- // @require data:application/javascript,var core = window.pervertmonkey.core || pervertmonkey.core; var utils = core;
16
+ // @require https://cdn.jsdelivr.net/npm/pervert-monkey@1.0.26/dist/core/pervertmonkey.core.umd.js
18
17
  // @grant GM_addStyle
19
18
  // @grant unsafeWindow
20
19
  // @run-at document-idle
21
20
  // ==/UserScript==
22
21
 
23
- (function (core, utils) {
24
- 'use strict';
22
+ var ___core = window.pervertmonkey.core || pervertmonkey.core;
23
+ var ___utils = ___core;
25
24
 
26
- class LSKDB {
27
- constructor(prefix = "lsm-", lockKey = "lsmngr-lock") {
28
- this.prefix = prefix;
29
- this.lockKey = lockKey;
30
- }
31
- prefixedKey(key) {
32
- return `${this.prefix}${key}`;
33
- }
34
- getAllKeys() {
35
- const res = [];
36
- for (const key in localStorage) {
37
- if (key.startsWith(this.prefix)) {
38
- res.push(key.slice(this.prefix.length));
39
- }
40
- }
41
- return res;
42
- }
43
- getKeys(n = 12, remove = true) {
44
- const res = [];
45
- for (const key in localStorage) {
46
- if (res.length >= n) break;
47
- if (key.startsWith(this.prefix)) {
48
- res.push(key.slice(this.prefix.length));
49
- }
50
- }
51
- if (remove) {
52
- res.forEach((k) => this.removeKey(k));
53
- }
54
- return res;
55
- }
56
- hasKey(key) {
57
- return localStorage.getItem(this.prefixedKey(key)) !== null;
58
- }
59
- removeKey(key) {
60
- localStorage.removeItem(this.prefixedKey(key));
61
- }
62
- setKey(key) {
63
- localStorage.setItem(this.prefixedKey(key), "");
64
- }
65
- isLocked() {
66
- const lock = parseInt(localStorage.getItem(this.lockKey));
67
- const locktime = 5 * 60 * 1e3;
68
- return !(!lock || Date.now() - lock > locktime);
69
- }
70
- lock(value) {
71
- if (value) {
72
- localStorage.setItem(this.lockKey, JSON.stringify(Date.now()));
73
- } else {
74
- localStorage.removeItem(this.lockKey);
75
- }
76
- }
77
- }
78
25
 
79
- var _GM_addStyle = (() => typeof GM_addStyle != "undefined" ? GM_addStyle : undefined)();
80
- var _unsafeWindow = (() => typeof unsafeWindow != "undefined" ? unsafeWindow : undefined)();
81
-
82
- const $ = _unsafeWindow.$;
83
- _GM_addStyle(`
26
+ (function(___core, ___utils) {
27
+ "use strict";
28
+ var LSKDB = class {
29
+ constructor(prefix = "lsm-", lockKey = "lsmngr-lock") {
30
+ this.prefix = prefix;
31
+ this.lockKey = lockKey;
32
+ }
33
+ prefixedKey(key) {
34
+ return `${this.prefix}${key}`;
35
+ }
36
+ getAllKeys() {
37
+ const res = [];
38
+ for (const key in localStorage) if (key.startsWith(this.prefix)) res.push(key.slice(this.prefix.length));
39
+ return res;
40
+ }
41
+ getKeys(n = 12, remove = true) {
42
+ const res = [];
43
+ for (const key in localStorage) {
44
+ if (res.length >= n) break;
45
+ if (key.startsWith(this.prefix)) res.push(key.slice(this.prefix.length));
46
+ }
47
+ if (remove) res.forEach((k) => this.removeKey(k));
48
+ return res;
49
+ }
50
+ hasKey(key) {
51
+ return localStorage.getItem(this.prefixedKey(key)) !== null;
52
+ }
53
+ removeKey(key) {
54
+ localStorage.removeItem(this.prefixedKey(key));
55
+ }
56
+ setKey(key) {
57
+ localStorage.setItem(this.prefixedKey(key), "");
58
+ }
59
+ isLocked() {
60
+ const lock = parseInt(localStorage.getItem(this.lockKey));
61
+ return !(!lock || Date.now() - lock > 300 * 1e3);
62
+ }
63
+ lock(value) {
64
+ if (value) localStorage.setItem(this.lockKey, JSON.stringify(Date.now()));
65
+ else localStorage.removeItem(this.lockKey);
66
+ }
67
+ };
68
+ var _GM_addStyle = (() => typeof GM_addStyle != "undefined" ? GM_addStyle : void 0)();
69
+ var $ = (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)().$;
70
+ _GM_addStyle(`
84
71
  .item.private .thumb, .item .thumb.private { opacity: 1 !important; }
85
72
  .haveNoAccess { background: linear-gradient(to bottom, #b50000 0%, #2c2c2c 100%) red !important; }
86
73
  .haveAccess { background: linear-gradient(to bottom, #4e9299 0%, #2c2c2c 100%) green !important; }
87
74
  .friend-button { background: radial-gradient(#5ccbf4, #e1ccb1) !important; }
88
75
  `);
89
- const IS_MEMBER_PAGE = /^(\/members\/\d+\/|\/my\/)$/.test(location.pathname);
90
- const IS_MESSAGES = /^\/my\/messages\//.test(location.pathname);
91
- const IS_COMMUNITY_LIST = /\/members\/$/.test(location.pathname);
92
- const IS_VIDEO_PAGE = /^(\/videos)?\/\d+\//.test(location.pathname);
93
- const IS_LOGGED_IN = document.cookie.includes("kt_member");
94
- const rules = new core.Rules({
95
- containerSelector: '[id*="playlist"]:has(> .item .title),[id*="videos"]:has(> .item .title),form:has(>.item .title)',
96
- paginationStrategyOptions: {
97
- paginationSelector: ".pagination:not([id *= member])",
98
- overwritePaginationLast: IS_MEMBER_PAGE ? () => 1 : (x) => x === 9 ? 9999 : x
99
- },
100
- thumbs: {
101
- selector: ".list-videos .item, .playlist .item, .list-playlists > div > .item, .item:has(.title)"
102
- },
103
- thumb: {
104
- strategy: "auto-select",
105
- selectors: {
106
- private: { type: "boolean", selector: "[class*=private]" },
107
- views: { selector: ".views", type: "float" }
108
- }
109
- },
110
- thumbImg: {
111
- selector: "data-original"
112
- },
113
- gropeStrategy: "all-in-all",
114
- schemeOptions: [
115
- "Title Filter",
116
- "Duration Filter",
117
- "Privacy Filter",
118
- "Sort By",
119
- "Badge",
120
- {
121
- title: "Advanced",
122
- content: [
123
- {
124
- autoRequestAccess: false,
125
- label: "auto send friend request on check access"
126
- }
127
- ]
128
- }
129
- ],
130
- animatePreview
131
- });
132
- function animatePreview(container) {
133
- const tick = new utils.Tick(500);
134
- function killjquery(n = 10) {
135
- if (n > 0) {
136
- n--;
137
- $("img[data-cnt]").off();
138
- setTimeout(() => killjquery(n), 250);
139
- }
140
- }
141
- killjquery();
142
- function rotateImg(src, count) {
143
- return src.replace(/(\d)(?=\.jpg$)/, (_, n) => `${utils.circularShift(parseInt(n), count)}`);
144
- }
145
- utils.OnHover.create(
146
- container,
147
- ".list-videos .item, .playlist .item, .list-playlists > div > .item, .item:has(.title)",
148
- (e) => {
149
- const img = e.querySelector("img");
150
- const origin = img.src;
151
- const count = parseInt(img.getAttribute("data-cnt")) || 5;
152
- tick.start(
153
- () => {
154
- img.src = rotateImg(img.src, count);
155
- },
156
- () => {
157
- img.src = origin;
158
- }
159
- );
160
- return () => tick.stop();
161
- }
162
- );
163
- }
164
- const createDownloadButton = () => utils.downloader({
165
- append: ".tabs-menu > ul",
166
- buttonHtml: '<li><a href="#tab_comments" class="toggle-button" style="text-decoration: none;">download 📼</a></li>',
167
- doBefore: () => $(".fp-ui").click()
168
- });
169
- const DEFAULT_FRIEND_REQUEST_FORMDATA = utils.objectToFormData({
170
- message: "",
171
- action: "add_to_friends_complete",
172
- function: "get_block",
173
- block_id: "member_profile_view_view_profile",
174
- format: "json",
175
- mode: "async"
176
- });
177
- const lskdb = new LSKDB();
178
- async function friendRequest(id) {
179
- const url = Number.isInteger(id) ? `${location.origin}/members/${id}/` : id;
180
- await fetch(url, { body: DEFAULT_FRIEND_REQUEST_FORMDATA, method: "post" });
181
- }
182
- function getMemberLinks(e) {
183
- return Array.from(
184
- e?.querySelectorAll(".item > a") || [],
185
- (l) => l.href
186
- ).filter((l) => /\/members\/\d+\/$/.test(l));
187
- }
188
- async function getMemberFriends(id) {
189
- const url = new URL(
190
- IS_COMMUNITY_LIST ? "/members/" : `/members/${id}/friends/`,
191
- location.origin
192
- );
193
- const doc = await utils.fetchHtml(url.href);
194
- const paginationStrategy = core.getPaginationStrategy({
195
- doc,
196
- url,
197
- overwritePaginationLast: (x) => x === 9 ? 999 : x
198
- });
199
- const gen = core.InfiniteScroller.generatorForPaginationStrategy(paginationStrategy);
200
- for (const url2 in gen) {
201
- const doc2 = await utils.fetchHtml(url2);
202
- getMemberLinks(doc2).forEach((a) => {
203
- const id2 = a.match(/\d+/)?.[0];
204
- lskdb.setKey(id2);
205
- });
206
- }
207
- await processFriendship();
208
- }
209
- let processFriendshipStarted = false;
210
- async function processFriendship(batchSize = 1, interval = 5e3) {
211
- if (lskdb.isLocked()) return;
212
- const friendlist = lskdb.getKeys(batchSize);
213
- if (friendlist?.length < 1) return;
214
- if (!processFriendshipStarted) {
215
- processFriendshipStarted = true;
216
- console.log("processFriendshipStarted");
217
- }
218
- lskdb.lock(true);
219
- const urls = friendlist.map((id) => `${location.origin}/members/${id}/`);
220
- for (const url of urls) {
221
- await utils.wait(interval);
222
- await friendRequest(url);
223
- }
224
- lskdb.lock(false);
225
- await processFriendship();
226
- }
227
- function createPrivateVideoFriendButton() {
228
- if (!document.querySelector(".no-player")) return;
229
- const member = document.querySelector(".no-player a")?.href;
230
- const button = utils.parseHtml(
231
- '<button class="friend-button"><span>Friend Request</span></button>'
232
- );
233
- document.querySelector(".no-player .message")?.append(button);
234
- button.addEventListener("click", () => friendRequest(member), { once: true });
235
- }
236
- function createFriendButton() {
237
- const button = utils.parseHtml(
238
- '<a href="#friend_everyone" class="button friend-button"><span>Friend Everyone</span></a>'
239
- );
240
- document.querySelector(".main-container-user > .headline, .headline")?.append(button);
241
- const memberid = location.pathname.match(/\d+/)?.[0];
242
- button.addEventListener(
243
- "click",
244
- () => {
245
- button.style.background = "radial-gradient(#ff6114, #5babc4)";
246
- button.innerText = "processing requests";
247
- getMemberFriends(memberid).then(() => {
248
- button.style.background = "radial-gradient(blue, lightgreen)";
249
- button.innerText = "friend requests sent";
250
- });
251
- },
252
- { once: true }
253
- );
254
- }
255
- async function requestAccess() {
256
- checkPrivateVidsAccess();
257
- setTimeout(processFriendship, 5e3);
258
- }
259
- async function checkPrivateVidsAccess() {
260
- const checkAccess = async (item) => {
261
- const videoURL = item.firstElementChild.href;
262
- const doc = await utils.fetchHtml(videoURL);
263
- if (!doc.querySelector(".player")) return;
264
- const haveAccess = !doc.querySelector(".no-player");
265
- if (!haveAccess && rules.store.state.autoRequestAccess) {
266
- const anchor = doc.querySelector(".message a");
267
- const uid = anchor?.href.match(/\d+/)?.at(-1);
268
- lskdb.setKey(uid);
269
- }
270
- item.classList.add(haveAccess ? "haveAccess" : "haveNoAccess");
271
- };
272
- const thumbs = document.querySelectorAll(
273
- ".item.private:not(.haveAccess,.haveNoAccess)"
274
- );
275
- for (const thumb of thumbs) {
276
- await checkAccess(thumb);
277
- }
278
- }
279
- function getUserInfo(e) {
280
- const uploadedCount = utils.querySelectorLastNumber("#list_videos_uploaded_videos strong", e);
281
- const friendsCount = utils.querySelectorLastNumber("#list_members_friends .headline", e);
282
- return { uploadedCount, friendsCount };
283
- }
284
- async function acceptFriendRequest(id) {
285
- const url = new URL(`/my/messages/${id}/`, location.origin);
286
- const memberUrl = new URL(`/members/${id}/`, location.origin);
287
- await fetch(url, {
288
- headers: {
289
- Accept: "*/*",
290
- "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
291
- },
292
- body: `action=confirm_add_to_friends&message_from_user_id=${id}&function=get_block&block_id=list_messages_my_conversation_messages&confirm=Confirm&format=json&mode=async`,
293
- method: "POST"
294
- });
295
- await utils.fetchHtml(memberUrl).then(
296
- (doc) => console.log("userInfo", memberUrl.href, getUserInfo(doc))
297
- );
298
- }
299
- async function clearMessages() {
300
- const pages = core.InfiniteScroller.generatorForPaginationStrategy(
301
- core.getPaginationStrategy({
302
- overwritePaginationLast: (x) => x === 9 ? 999 : x
303
- })
304
- );
305
- for await (const p of pages) {
306
- const doc = await utils.fetchHtml(p.url);
307
- const messages = Array.from(
308
- doc.querySelectorAll(
309
- "#list_members_my_conversations_items .item > a"
310
- ) || []
311
- ).map((a) => a.href);
312
- for (const m of messages) {
313
- await checkMessageHistory(m);
314
- }
315
- }
316
- async function deleteMessage(url, id) {
317
- const deleteURL = `${url}?mode=async&format=json&function=get_block&block_id=list_messages_my_conversation_messages&action=delete_conversation&conversation_user_id=${id}`;
318
- await fetch(deleteURL);
319
- }
320
- async function getConversation(url) {
321
- const doc = await utils.fetchHtml(url);
322
- const hasFriendRequest = !!doc.querySelector("input[value=confirm_add_to_friends]");
323
- const originalText = utils.querySelectorText(doc, ".original-text");
324
- const id = url.match(/\d+/)?.[0];
325
- const messages = utils.querySelectorText(doc, ".list-messages");
326
- return {
327
- id,
328
- hasFriendRequest,
329
- originalText,
330
- messages
331
- };
332
- }
333
- async function checkMessageHistory(url) {
334
- const { originalText, hasFriendRequest, id, messages } = await getConversation(url);
335
- if (!(originalText || hasFriendRequest)) {
336
- await deleteMessage(url, id);
337
- } else {
338
- console.log({ originalText, url, messages });
339
- if (hasFriendRequest) {
340
- await acceptFriendRequest(id);
341
- }
342
- }
343
- }
344
- }
345
- const FRIEND_REQUEST_INTERVAL = 5e3;
346
- if (IS_LOGGED_IN) {
347
- setTimeout(processFriendship, FRIEND_REQUEST_INTERVAL);
348
- if (IS_MEMBER_PAGE || IS_COMMUNITY_LIST) {
349
- createFriendButton();
350
- }
351
- }
352
- if (IS_VIDEO_PAGE) {
353
- createDownloadButton();
354
- createPrivateVideoFriendButton();
355
- }
356
- if (IS_MESSAGES) {
357
- const button = utils.parseHtml("<button>clear messages</button>");
358
- document.querySelector(".headline")?.append(button);
359
- button.addEventListener("click", clearMessages);
360
- }
361
- rules.store.eventSubject.subscribe((event) => {
362
- if (event.includes("check access")) {
363
- requestAccess();
364
- }
365
- });
366
-
367
- })(core, utils);
76
+ var IS_MEMBER_PAGE = /^(\/members\/\d+\/|\/my\/)$/.test(location.pathname);
77
+ var IS_MESSAGES = /^\/my\/messages\//.test(location.pathname);
78
+ var IS_COMMUNITY_LIST = /\/members\/$/.test(location.pathname);
79
+ var IS_VIDEO_PAGE = /^(\/videos)?\/\d+\//.test(location.pathname);
80
+ var IS_LOGGED_IN = document.cookie.includes("kt_member");
81
+ var rules = new ___core.Rules({
82
+ containerSelector: "[id*=\"playlist\"]:has(> .item .title),[id*=\"videos\"]:has(> .item .title),form:has(>.item .title)",
83
+ paginationStrategyOptions: {
84
+ paginationSelector: ".pagination:not([id *= member])",
85
+ overwritePaginationLast: IS_MEMBER_PAGE ? () => 1 : (x) => x === 9 ? 9999 : x
86
+ },
87
+ thumbs: { selector: ".list-videos .item, .playlist .item, .list-playlists > div > .item, .item:has(.title)" },
88
+ thumb: {
89
+ strategy: "auto-select",
90
+ selectors: {
91
+ private: {
92
+ type: "boolean",
93
+ selector: "[class*=private]"
94
+ },
95
+ views: {
96
+ selector: ".views",
97
+ type: "float"
98
+ }
99
+ }
100
+ },
101
+ thumbImg: { selector: "data-original" },
102
+ gropeStrategy: "all-in-all",
103
+ schemeOptions: [
104
+ "Title Filter",
105
+ "Duration Filter",
106
+ "Privacy Filter",
107
+ "Sort By",
108
+ "Badge",
109
+ {
110
+ title: "Advanced",
111
+ content: [{
112
+ autoRequestAccess: false,
113
+ label: "auto send friend request on check access"
114
+ }]
115
+ }
116
+ ],
117
+ animatePreview
118
+ });
119
+ function animatePreview(container) {
120
+ const tick = new ___utils.Tick(500);
121
+ function killjquery(n = 10) {
122
+ if (n > 0) {
123
+ n--;
124
+ $("img[data-cnt]").off();
125
+ setTimeout(() => killjquery(n), 250);
126
+ }
127
+ }
128
+ killjquery();
129
+ function rotateImg(src, count) {
130
+ return src.replace(/(\d)(?=\.jpg$)/, (_, n) => `${(0, ___utils.circularShift)(parseInt(n), count)}`);
131
+ }
132
+ ___utils.OnHover.create(container, ".list-videos .item, .playlist .item, .list-playlists > div > .item, .item:has(.title)", (e) => {
133
+ const img = e.querySelector("img");
134
+ const origin = img.src;
135
+ const count = parseInt(img.getAttribute("data-cnt")) || 5;
136
+ tick.start(() => {
137
+ img.src = rotateImg(img.src, count);
138
+ }, () => {
139
+ img.src = origin;
140
+ });
141
+ return () => tick.stop();
142
+ });
143
+ }
144
+ var createDownloadButton = () => (0, ___utils.downloader)({
145
+ append: ".tabs-menu > ul",
146
+ buttonHtml: "<li><a href=\"#tab_comments\" class=\"toggle-button\" style=\"text-decoration: none;\">download 📼</a></li>",
147
+ doBefore: () => $(".fp-ui").click()
148
+ });
149
+ var DEFAULT_FRIEND_REQUEST_FORMDATA = (0, ___utils.objectToFormData)({
150
+ message: "",
151
+ action: "add_to_friends_complete",
152
+ function: "get_block",
153
+ block_id: "member_profile_view_view_profile",
154
+ format: "json",
155
+ mode: "async"
156
+ });
157
+ var lskdb = new LSKDB();
158
+ async function friendRequest(id) {
159
+ const url = Number.isInteger(id) ? `${location.origin}/members/${id}/` : id;
160
+ await fetch(url, {
161
+ body: DEFAULT_FRIEND_REQUEST_FORMDATA,
162
+ method: "post"
163
+ });
164
+ }
165
+ function getMemberLinks(e) {
166
+ return Array.from(e?.querySelectorAll(".item > a") || [], (l) => l.href).filter((l) => /\/members\/\d+\/$/.test(l));
167
+ }
168
+ async function getMemberFriends(id) {
169
+ const url = new URL(IS_COMMUNITY_LIST ? "/members/" : `/members/${id}/friends/`, location.origin);
170
+ const paginationStrategy = (0, ___core.getPaginationStrategy)({
171
+ doc: await (0, ___utils.fetchHtml)(url.href),
172
+ url,
173
+ overwritePaginationLast: (x) => x === 9 ? 999 : x
174
+ });
175
+ const gen = ___core.InfiniteScroller.generatorForPaginationStrategy(paginationStrategy);
176
+ for (const url in gen) getMemberLinks(await (0, ___utils.fetchHtml)(url)).forEach((a) => {
177
+ const id = a.match(/\d+/)?.[0];
178
+ lskdb.setKey(id);
179
+ });
180
+ await processFriendship();
181
+ }
182
+ var processFriendshipStarted = false;
183
+ async function processFriendship(batchSize = 1, interval = 5e3) {
184
+ if (lskdb.isLocked()) return;
185
+ const friendlist = lskdb.getKeys(batchSize);
186
+ if (friendlist?.length < 1) return;
187
+ if (!processFriendshipStarted) {
188
+ processFriendshipStarted = true;
189
+ console.log("processFriendshipStarted");
190
+ }
191
+ lskdb.lock(true);
192
+ const urls = friendlist.map((id) => `${location.origin}/members/${id}/`);
193
+ for (const url of urls) {
194
+ await (0, ___utils.wait)(interval);
195
+ await friendRequest(url);
196
+ }
197
+ lskdb.lock(false);
198
+ await processFriendship();
199
+ }
200
+ function createPrivateVideoFriendButton() {
201
+ if (!document.querySelector(".no-player")) return;
202
+ const member = document.querySelector(".no-player a")?.href;
203
+ const button = (0, ___utils.parseHtml)("<button class=\"friend-button\"><span>Friend Request</span></button>");
204
+ document.querySelector(".no-player .message")?.append(button);
205
+ button.addEventListener("click", () => friendRequest(member), { once: true });
206
+ }
207
+ function createFriendButton() {
208
+ const button = (0, ___utils.parseHtml)("<a href=\"#friend_everyone\" class=\"button friend-button\"><span>Friend Everyone</span></a>");
209
+ document.querySelector(".main-container-user > .headline, .headline")?.append(button);
210
+ const memberid = location.pathname.match(/\d+/)?.[0];
211
+ button.addEventListener("click", () => {
212
+ button.style.background = "radial-gradient(#ff6114, #5babc4)";
213
+ button.innerText = "processing requests";
214
+ getMemberFriends(memberid).then(() => {
215
+ button.style.background = "radial-gradient(blue, lightgreen)";
216
+ button.innerText = "friend requests sent";
217
+ });
218
+ }, { once: true });
219
+ }
220
+ async function requestAccess() {
221
+ checkPrivateVidsAccess();
222
+ setTimeout(processFriendship, 5e3);
223
+ }
224
+ async function checkPrivateVidsAccess() {
225
+ const checkAccess = async (item) => {
226
+ const videoURL = item.firstElementChild.href;
227
+ const doc = await (0, ___utils.fetchHtml)(videoURL);
228
+ if (!doc.querySelector(".player")) return;
229
+ const haveAccess = !doc.querySelector(".no-player");
230
+ if (!haveAccess && rules.store.state.autoRequestAccess) {
231
+ const uid = doc.querySelector(".message a")?.href.match(/\d+/)?.at(-1);
232
+ lskdb.setKey(uid);
233
+ }
234
+ item.classList.add(haveAccess ? "haveAccess" : "haveNoAccess");
235
+ };
236
+ const thumbs = document.querySelectorAll(".item.private:not(.haveAccess,.haveNoAccess)");
237
+ for (const thumb of thumbs) await checkAccess(thumb);
238
+ }
239
+ function getUserInfo(e) {
240
+ return {
241
+ uploadedCount: (0, ___utils.querySelectorLastNumber)("#list_videos_uploaded_videos strong", e),
242
+ friendsCount: (0, ___utils.querySelectorLastNumber)("#list_members_friends .headline", e)
243
+ };
244
+ }
245
+ async function acceptFriendRequest(id) {
246
+ const url = new URL(`/my/messages/${id}/`, location.origin);
247
+ const memberUrl = new URL(`/members/${id}/`, location.origin);
248
+ await fetch(url, {
249
+ headers: {
250
+ Accept: "*/*",
251
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
252
+ },
253
+ body: `action=confirm_add_to_friends&message_from_user_id=${id}&function=get_block&block_id=list_messages_my_conversation_messages&confirm=Confirm&format=json&mode=async`,
254
+ method: "POST"
255
+ });
256
+ await (0, ___utils.fetchHtml)(memberUrl).then((doc) => console.log("userInfo", memberUrl.href, getUserInfo(doc)));
257
+ }
258
+ async function clearMessages() {
259
+ const pages = ___core.InfiniteScroller.generatorForPaginationStrategy((0, ___core.getPaginationStrategy)({ overwritePaginationLast: (x) => x === 9 ? 999 : x }));
260
+ for await (const p of pages) {
261
+ const doc = await (0, ___utils.fetchHtml)(p.url);
262
+ const messages = Array.from(doc.querySelectorAll("#list_members_my_conversations_items .item > a") || []).map((a) => a.href);
263
+ for (const m of messages) await checkMessageHistory(m);
264
+ }
265
+ async function deleteMessage(url, id) {
266
+ const deleteURL = `${url}?mode=async&format=json&function=get_block&block_id=list_messages_my_conversation_messages&action=delete_conversation&conversation_user_id=${id}`;
267
+ await fetch(deleteURL);
268
+ }
269
+ async function getConversation(url) {
270
+ const doc = await (0, ___utils.fetchHtml)(url);
271
+ const hasFriendRequest = !!doc.querySelector("input[value=confirm_add_to_friends]");
272
+ const originalText = (0, ___utils.querySelectorText)(doc, ".original-text");
273
+ return {
274
+ id: url.match(/\d+/)?.[0],
275
+ hasFriendRequest,
276
+ originalText,
277
+ messages: (0, ___utils.querySelectorText)(doc, ".list-messages")
278
+ };
279
+ }
280
+ async function checkMessageHistory(url) {
281
+ const { originalText, hasFriendRequest, id, messages } = await getConversation(url);
282
+ if (!(originalText || hasFriendRequest)) await deleteMessage(url, id);
283
+ else {
284
+ console.log({
285
+ originalText,
286
+ url,
287
+ messages
288
+ });
289
+ if (hasFriendRequest) await acceptFriendRequest(id);
290
+ }
291
+ }
292
+ }
293
+ var FRIEND_REQUEST_INTERVAL = 5e3;
294
+ if (IS_LOGGED_IN) {
295
+ setTimeout(processFriendship, FRIEND_REQUEST_INTERVAL);
296
+ if (IS_MEMBER_PAGE || IS_COMMUNITY_LIST) createFriendButton();
297
+ }
298
+ if (IS_VIDEO_PAGE) {
299
+ createDownloadButton();
300
+ createPrivateVideoFriendButton();
301
+ }
302
+ if (IS_MESSAGES) {
303
+ const button = (0, ___utils.parseHtml)("<button>clear messages</button>");
304
+ document.querySelector(".headline")?.append(button);
305
+ button.addEventListener("click", clearMessages);
306
+ }
307
+ rules.store.eventSubject.subscribe((event) => {
308
+ if (event.includes("check access")) requestAccess();
309
+ });
310
+ })(___core, ___utils);