lrkmusic-ytpro 1.0.1 → 1.0.2
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.
- package/package.json +1 -1
- package/script.js +46 -26
package/package.json
CHANGED
package/script.js
CHANGED
|
@@ -338,42 +338,62 @@ compactDisplay: "short",
|
|
|
338
338
|
|
|
339
339
|
|
|
340
340
|
|
|
341
|
-
/*Auto-play Next Video - YouTube
|
|
341
|
+
/*Auto-play Next Video - YouTube / playlist / Mix: video end hone par next auto play, pause nahi*/
|
|
342
342
|
function setupAutoPlayNext() {
|
|
343
343
|
try {
|
|
344
344
|
var player = document.getElementsByClassName('video-stream')[0];
|
|
345
345
|
if (player && !player.hasAttribute('data-autoplay-setup')) {
|
|
346
346
|
player.setAttribute('data-autoplay-setup', 'true');
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
// Try to find and click the next video button
|
|
352
|
-
var nextButton = document.querySelector('ytm-pivot-bar-item-renderer[tab-id="NEXT"]') ||
|
|
353
|
-
document.querySelector('[aria-label*="Next"]') ||
|
|
347
|
+
|
|
348
|
+
function tryPlayNext() {
|
|
349
|
+
try {
|
|
350
|
+
var nextButton = document.querySelector('.ytp-next-button') ||
|
|
354
351
|
document.querySelector('button[aria-label*="Next"]') ||
|
|
355
|
-
document.querySelector('
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
352
|
+
document.querySelector('button[aria-label*="next"]') ||
|
|
353
|
+
document.querySelector('[aria-label*="Next"]') ||
|
|
354
|
+
document.querySelector('ytm-pivot-bar-item-renderer[tab-id="NEXT"]') ||
|
|
355
|
+
document.querySelector('tp-yt-paper-icon-button[aria-label*="Next"]');
|
|
356
|
+
if (nextButton) {
|
|
357
|
+
nextButton.click();
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
var playlistRows = document.querySelectorAll('ytm-playlist-panel-video-renderer, ytm-compact-video-renderer');
|
|
361
|
+
for (var i = 0; i < playlistRows.length; i++) {
|
|
362
|
+
var row = playlistRows[i];
|
|
363
|
+
var isCurrent = row.hasAttribute && (row.hasAttribute('playing') || row.hasAttribute('aria-current') || (row.classList && row.classList.contains('playing')));
|
|
364
|
+
if (!isCurrent) continue;
|
|
365
|
+
var nextRow = row.nextElementSibling;
|
|
366
|
+
while (nextRow) {
|
|
367
|
+
var nextA = nextRow.querySelector && nextRow.querySelector('a[href*="/watch"]');
|
|
368
|
+
if (nextA && nextA.href) {
|
|
369
|
+
window.location.href = nextA.href;
|
|
370
|
+
return true;
|
|
366
371
|
}
|
|
372
|
+
nextRow = nextRow.nextElementSibling;
|
|
367
373
|
}
|
|
368
|
-
|
|
369
|
-
console.log("Auto-play next error:", e);
|
|
374
|
+
break;
|
|
370
375
|
}
|
|
371
|
-
|
|
376
|
+
var upNext = document.querySelector('ytm-compact-video-renderer a[href*="/watch"]') ||
|
|
377
|
+
document.querySelector('ytm-video-with-context-renderer a[href*="/watch"]') ||
|
|
378
|
+
document.querySelector('a[href*="/watch"].ytm-compact-video-renderer');
|
|
379
|
+
if (upNext && upNext.href) {
|
|
380
|
+
window.location.href = upNext.href;
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
} catch (e) {}
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
player.addEventListener('ended', function() {
|
|
388
|
+
var attempts = [400, 900, 1600];
|
|
389
|
+
attempts.forEach(function(delay) {
|
|
390
|
+
setTimeout(function() {
|
|
391
|
+
if (tryPlayNext()) return;
|
|
392
|
+
}, delay);
|
|
393
|
+
});
|
|
372
394
|
});
|
|
373
395
|
}
|
|
374
|
-
} catch (e) {
|
|
375
|
-
// Silently fail
|
|
376
|
-
}
|
|
396
|
+
} catch (e) {}
|
|
377
397
|
}
|
|
378
398
|
|
|
379
399
|
/* Shorts: when user does NOT scroll, auto-scroll to next short when current video ends */
|
|
@@ -2376,7 +2396,7 @@ window.fetch = async function(input, init) {
|
|
|
2376
2396
|
try {
|
|
2377
2397
|
const url = (typeof input === 'string') ? input : (input&&input.url) || "";
|
|
2378
2398
|
if(isAdUrl(url)){
|
|
2379
|
-
return new Response(
|
|
2399
|
+
return new Response(JSON.stringify({}), {status:200, headers:{"Content-Type":"application/json"}});
|
|
2380
2400
|
}
|
|
2381
2401
|
const response = await _origFetch.apply(this, arguments);
|
|
2382
2402
|
try {
|