Skip to content

Commit 06d3b0d

Browse files
authored
Merge pull request #1184 from Vieller/patch-1
Update pagetualRules.json
2 parents 713353b + 66fbf83 commit 06d3b0d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Pagetual/pagetualRules.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6487,5 +6487,14 @@
64876487
"replaceElement": "div.product-card",
64886488
"pageElement": "div.products-catalog__list",
64896489
"action": 2
6490-
}
6490+
},
6491+
{
6492+
"name": "xHamster",
6493+
"url": "^https://([\\w]+\\.)?(xhamster|xhaccess|xhamster19)\\.(com|desi)/",
6494+
"pageElement": "//div[contains(@class, 'thumb-list__item') and not(contains(@class, 'loading'))]",
6495+
"nextLink": "//a[@data-page='next' or @rel='next']",
6496+
"action": 0,
6497+
"pageInit": "if (!window._pagetualMasterTemplate) { let masterElem = document.querySelector('.thumb-list__item'); if (masterElem) window._pagetualMasterTemplate = masterElem.innerHTML; } let template = document.querySelector('.thumb-list__item'); let inner = window._pagetualMasterTemplate || (template ? template.innerHTML : ''); if (!inner) return; let script = doc.querySelector('script#initials-script'); if (!script) { script = Array.from(doc.querySelectorAll('script')).find(s => s.textContent.includes('window.initials=')); } if (!script) return; let scriptText = script.textContent; let match = scriptText.match(/window\\.initials\\s*=\\s*(\\{[\\s\\S]*?\\});/); if (!match) return; let jsonStr = match[1]; let initials; try { initials = eval('(' + jsonStr + ')'); } catch(e) { return; } function find(obj, depth) { if (depth > 10) return null; if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return null; if (obj.videoThumbProps?.length) return obj.videoThumbProps; for (let k in obj) if (obj.hasOwnProperty(k)) { let r = find(obj[k], depth+1); if (r) return r; } return null; } let props = find(initials, 0); if (!props?.length) return; function formatDuration(s) { let h = Math.floor(s/3600), m = Math.floor((s%3600)/60), sec = s%60; if (h) return h+':'+(m<10?'0'+m:m)+':'+(sec<10?'0'+sec:sec); return m+':'+(sec<10?'0'+sec:sec); } function formatViews(v) { if (v>=1e6) return Math.floor(v/1e6)+'M'; if (v>=1e3) return Math.floor(v/1e3)+'K'; return v.toString(); } for (let ele of eles) { let id = ele.getAttribute('data-video-id'); if (!id) continue; let data = props.find(p => p.id == id); if (!data) continue; let div = document.createElement('div'); div.innerHTML = inner; let noscripts = div.querySelectorAll('noscript'); for (let ns of noscripts) ns.remove(); let link = div.querySelector('a[data-role=\"thumb-link\"]'); if (link && data.pageURL) { link.href = data.pageURL; link.setAttribute('data-previewvideo', data.trailerURL || ''); link.setAttribute('aria-label', data.title || ''); } let img = div.querySelector('img.thumb-image-container__image'); if (img) { img.src = data.imageURL; img.srcset = data.thumbURL; img.alt = data.title || ''; } let sprite = div.querySelector('.thumb-image-container__sprite'); if (sprite) { sprite.setAttribute('data-sprite', data.spriteURL || ''); sprite.id = id; } let durationSpan = div.querySelector('[data-role=\"video-duration\"] .tiny-8643e'); if (durationSpan) durationSpan.textContent = formatDuration(data.duration); let uhd = div.querySelector('.xh-icon'); if (uhd && !data.isUHD) uhd.style.display = 'none'; let titleLink = div.querySelector('.video-thumb-info__name'); if (titleLink && data.pageURL) { titleLink.href = data.pageURL; titleLink.title = data.title || ''; titleLink.textContent = data.title || ''; } let uploaderData = div.querySelector('.video-uploader-data'); if (uploaderData) { if (data.landing && data.landing.name) { let logo = uploaderData.querySelector('.video-uploader-logo'); if (logo && data.landing.link) { logo.href = data.landing.link; logo.textContent = data.landing.name.charAt(0).toUpperCase(); } let name = uploaderData.querySelector('.video-uploader__name'); if (name && data.landing.link) { name.href = data.landing.link; name.textContent = data.landing.name; } } else { let logo = uploaderData.querySelector('.video-uploader-logo'); if (logo) logo.remove(); let name = uploaderData.querySelector('.video-uploader__name'); if (name) name.remove(); let sep = uploaderData.querySelector('.video-thumb-uploader__separator'); if (sep) sep.remove(); } } let viewsSpan = div.querySelector('.video-thumb-views'); if (viewsSpan) viewsSpan.textContent = formatViews(data.views) + ' views'; if (data.isWatched) { let onVideo = div.querySelector('.thumb-image-container__on-video'); if (onVideo && !onVideo.querySelector('.thumb-image-container__watched')) { let w = document.createElement('div'); w.className = 'thumb-image-container__watched'; w.setAttribute('data-role', 'video-watched'); w.innerHTML = '<div class=\"tiny-bold-8643e invert-8643e\">Watched</div>'; if (onVideo.firstChild) onVideo.insertBefore(w, onVideo.firstChild); else onVideo.appendChild(w); } } if (data.hasProducerBadge) { let a = div.querySelector('a[data-role=\"thumb-link\"]'); if (a && !a.querySelector('.thumb-image-container__badge')) { let b = document.createElement('div'); b.className = 'thumb-image-container__badge'; b.setAttribute('data-role-producer-badge', ''); b.setAttribute('data-brand', 'full video'); b.innerHTML = '<span class=\"badge-producer\"></span>'; a.appendChild(b); } } while (ele.firstChild) ele.removeChild(ele.firstChild); while (div.firstChild) ele.appendChild(div.firstChild); }",
6498+
"pageAction": "eles.forEach(container => { let anchor = container.querySelector('a[data-role=\"thumb-link\"]'); if (!anchor) return; let trailerUrl = anchor.getAttribute('data-previewvideo'); if (!trailerUrl) return; if (getComputedStyle(anchor).position !== 'relative') anchor.style.position = 'relative'; let videoElem = null; anchor.addEventListener('mouseenter', () => { if (videoElem) return; videoElem = Object.assign(document.createElement('video'), { src: trailerUrl, loop: true, muted: true, autoplay: true, playsInline: true }); Object.assign(videoElem.style, { position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', objectFit: 'cover', zIndex: 10, pointerEvents: 'none', backgroundColor: 'black' }); anchor.appendChild(videoElem); videoElem.play(); }); anchor.addEventListener('mouseleave', () => { if (!videoElem) return; videoElem.pause(); videoElem.remove(); videoElem = null; }); });"
6499+
}
64916500
]

0 commit comments

Comments
 (0)