diff --git a/.github/workflows/json-validator.yml b/.github/workflows/json-validator.yml index a726236d040..01911cc1730 100644 --- a/.github/workflows/json-validator.yml +++ b/.github/workflows/json-validator.yml @@ -13,9 +13,9 @@ jobs: - uses: actions/checkout@v4 - name: json-yaml-validate - uses: GrantBirki/json-yaml-validate@v3.0.0 + uses: GrantBirki/json-yaml-validate@v5 id: json-yaml-validate with: json_schema: Pagetual/pagetual.schema.json files: | - Pagetual/pagetualRules.json \ No newline at end of file + Pagetual/pagetualRules.json diff --git a/BingBgForBaidu/BingBgForBaidu.user.js b/BingBgForBaidu/BingBgForBaidu.user.js index 6c86b1050dd..ba0fa832396 100644 --- a/BingBgForBaidu/BingBgForBaidu.user.js +++ b/BingBgForBaidu/BingBgForBaidu.user.js @@ -2,7 +2,7 @@ // @name 百Bing图 // @name:en BingBgForBaidu // @namespace hoothin -// @version 2.3.44 +// @version 2.3.45 // @description 给百度首页换上Bing的背景图,并添加背景图链接与日历组件 // @description:en Just change the background image of baidu.com to bing.com // @author hoothin @@ -124,7 +124,10 @@ } }; var skinContainer=document.getElementsByTagName("body")[0]; - GM_addStyle(".s-news-rank-content{max-height: 180px; width: 99%; overflow-y: auto; overflow-x: hidden;}.s-top-right .ai-entry-right-nologin,.s-top-right .operate-wrapper-nologin{right:362px;}.hot-refresh{padding-bottom:7px;}.hot-title>div,.hot-refresh{border-radius: 3px 3px 0 0}.s-hotsearch-title>a,.s-hotsearch-title>a>div{padding: 5px;background-color: #f0f8ff95;border-radius: 5px;}.s-hotsearch-content{position: absolute; background-color: #f0f8ff95; border-radius: 5px;padding: 5px;}.s_ipt{margin:0!important;}.s_ipt_wr{border-radius: 10px 4px 4px 10px;border-radius: 10px 0 0 10px;background: #fff!important;}#qrcodeCon{display:none}body{position:fixed;_position:absolute;top:0;left:0;height:100%;width:100%;min-width:1000px;z-index:-10;background-position:center 0;background-repeat:no-repeat;background-size:cover;-webkit-background-size:cover;-o-background-size:cover;zoom:1;}"); + if (!document.querySelector(".aigc-skin-bg,#s_mancard_main")) { + GM_addStyle(".s-news-rank-content{max-height: 180px; width: 99%; overflow-y: auto; overflow-x: hidden;}.s-top-right .ai-entry-right-nologin,.s-top-right .operate-wrapper-nologin{right:362px;}.hot-refresh{padding-bottom:7px;}.hot-title>div,.hot-refresh{border-radius: 3px 3px 0 0}.s-hotsearch-title>a,.s-hotsearch-title>a>div{padding: 5px;background-color: #f0f8ff95;border-radius: 5px;}.s-hotsearch-content{position: absolute; background-color: #f0f8ff95; border-radius: 5px;padding: 5px;}"); + } + GM_addStyle(".s_ipt{margin:0!important;}.s_ipt_wr{border-radius: 10px 4px 4px 10px;border-radius: 10px 0 0 10px;background: #fff!important;}#qrcodeCon{display:none}body{position:fixed;_position:absolute;top:0;left:0;height:100%;width:100%;min-width:1000px;z-index:-10;background-position:center 0;background-repeat:no-repeat;background-size:cover;-webkit-background-size:cover;-o-background-size:cover;zoom:1;}"); var inputsu=document.querySelector("input#su"); var clickHandler=e=>{ if(skinContainer)skinContainer.style.backgroundImage=""; diff --git a/Pagetual/pagetual.user.js b/Pagetual/pagetual.user.js index 3ebfba30c69..ae4b3ad94f3 100644 --- a/Pagetual/pagetual.user.js +++ b/Pagetual/pagetual.user.js @@ -31,7 +31,7 @@ // @name:da Pagetual // @name:fr-CA Pagetual // @namespace hoothin -// @version 1.9.37.131 +// @version 1.9.37.132 // @description Perpetual pages - powerful auto-pager script. Auto fetching next paginated web pages and inserting into current page for infinite scroll. Support thousands of web sites without any rule. // @description:zh-CN 终极自动翻页 - 加载并拼接下一分页内容至当前页尾,智能适配任意网页 // @description:zh-TW 終極自動翻頁 - 加載並拼接下一分頁內容至當前頁尾,智能適配任意網頁 @@ -4513,7 +4513,7 @@ const wedataRulesUrl = "http://wedata.net/databases/AutoPagerize/items_all.json"; const wedataMirrorRulesUrl = "https://hoothin.github.io/UserScripts/Pagetual/items_all.json"; const guidePage = /^https?:\/\/.*pagetual.*rule\.html/i; - const ruleImportUrlReg = /greasyfork\.org\/.*scripts\/438684(\-[^\/]*)?(\/discussions|\/?$|\/feedback)|github\.com\/hoothin\/UserScripts\/(tree\/master\/Pagetual|issues)|^https:\/\/pagetual\.hoothin\.com\/.*firstRun\.html/i; + const ruleImportUrlReg = /greasyfork\.org\/.*scripts\/438684(\-[^\/]*)?(\/discussions|\/?$|\/feedback)|github\.com\/hoothin\/UserScripts\/(tree\/master\/Pagetual|issues)|^https:\/\/pagetual\.hoothin\.com\/.*first(Run|-run)\.html/i; const allOfBody = "body>*"; const mainSel = ["article,.article","[role=main],main,.main,#main","#results"]; const nextTextReg1 = new RegExp("\u005e\u7ffb\u003f\u005b\u4e0b\u540e\u5f8c\u6b21\u005d\u005b\u4e00\u30fc\u2500\u0031\u005d\u003f\u005b\u9875\u9801\u5f20\u5f35\u005d\u007c\u005e\u006e\u0065\u0078\u0074\u005b\u005c\u0073\u005f\u002d\u005d\u003f\u0070\u0061\u0067\u0065\u005c\u0073\u002a\u005b\u203a\u003e\u2192\u00bb\u005d\u003f\u0024\u007c\u6b21\u306e\u30da\u30fc\u30b8\u007c\u005e\u6b21\u3078\u0024\u007c\u0412\u043f\u0435\u0440\u0435\u0434\u007c\u005e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435", "i"); diff --git a/Pagetual/pagetualRules.json b/Pagetual/pagetualRules.json index f72854a3737..2b81ff29282 100644 --- a/Pagetual/pagetualRules.json +++ b/Pagetual/pagetualRules.json @@ -6487,5 +6487,16 @@ "replaceElement": "div.product-card", "pageElement": "div.products-catalog__list", "action": 2 +}, +{ + "name": "xHamster", + "url": "^https://([\\w]+\\.)?(xhamster|xhaccess|xhamster19)\\.(com|desi)/", + "author": "vieller", + "pageElement": "div:has(+ *[data-role*='pagination']), div:has(+ *[class*='pager-section']), div:has(+ *[class*='pagination-'])", + "nextLink": "a[data-page='next'], a[rel='next']", + "action": 1, + "init": "let candidates=Array.from(document.querySelectorAll('.thumb-list__item'));let bestCandidate=candidates.find(c=>c.querySelector('[data-role=\"video-duration\"]'));if(!bestCandidate&&candidates.length) bestCandidate=candidates[0];if(!window._pagetualMasterTemplateVideo){if(bestCandidate){let clone=bestCandidate.cloneNode(true);let badgeElements=clone.querySelectorAll('[data-role=\"video-watched\"], [data-brand=\"full video\"]');badgeElements.forEach(badge=>badge.remove());let xhIcons=clone.querySelectorAll('.xh-icon');xhIcons.forEach(icon=>icon.remove());window._pagetualMasterTemplateVideo=clone.innerHTML;let durationSpan=clone.querySelector('[data-role=\"video-duration\"] [class*=\"tiny-\"]');if(durationSpan){let tinyClass=Array.from(durationSpan.classList).find(c=>c.startsWith('tiny-'));if(tinyClass){let suffix=tinyClass.split('-').pop();if(suffix) window._pagetualSuffix=suffix;}}}} if(!window._pagetualMasterGallery){let galleryCandidates=Array.from(document.querySelectorAll('[class*=\"container-\"] > [class*=\"wrapper\"]'));if(!galleryCandidates.length) galleryCandidates=Array.from(document.querySelectorAll('div[class*=\"wrapper\"]')).filter(el=>el.querySelector('[class*=\"author-\"]'));let bestGallery=galleryCandidates.find(g=>g.querySelector('[class*=\"author-\"]'));if(!bestGallery&&galleryCandidates.length) bestGallery=galleryCandidates[0];if(bestGallery){let clone=bestGallery.cloneNode(true);window._pagetualMasterGallery=clone.innerHTML;let captionSpan=clone.querySelector('[class*=\"caption-\"]');if(captionSpan){let captionClass=Array.from(captionSpan.classList).find(c=>c.startsWith('caption-'));if(captionClass) window._pagetualCaptionSuffix=captionClass.split('-').pop();} let bodySpan=clone.querySelector('[class*=\"body-bold-\"]');if(bodySpan){let bodyClass=Array.from(bodySpan.classList).find(c=>c.startsWith('body-bold-'));if(bodyClass) window._pagetualBodySuffix=bodyClass.split('-').pop();}}} if(!window._pagetualSuffix) window._pagetualSuffix='8643e';if(!window._pagetualCaptionSuffix) window._pagetualCaptionSuffix='8643e';if(!window._pagetualBodySuffix) window._pagetualBodySuffix='8643e';if(!window._pagetualFriendsOnlyTemplate){let rootClass='root-'+window._pagetualSuffix;let iconClass='icon-'+window._pagetualSuffix;window._pagetualFriendsOnlyTemplate=`
Friends only
`;}", + "pageInit": "let container = eles[0]; if (!container) return; /* Extract data from window.initials and handle different page types */ 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;} /* Regular photo gallery (no hydration, remove skeleton overlays only) */ let skeletonSelector = 'a[class*=\"cover\"] > div[class*=\"container-\"][class*=\"primaryColor-\"]'; let loadingSkeleton = container.querySelector(skeletonSelector); /* if (initials.photosPage !== undefined || initials.galleryPage !== undefined) { */ if (loadingSkeleton) { let galleryItemSelector = 'div[class*=\"wrapper\"], div[style]:not([class])'; let galleryItems = container.querySelectorAll(galleryItemSelector); for (let ele of galleryItems) { /* let skeleton = ele.querySelector('a[class*=\"cover\"] > div[class*=\"container-\"][class*=\"primaryColor-\"]'); */ let skeleton = ele.querySelector(skeletonSelector); if (skeleton && skeleton.querySelector('span[class*=\"dot\"]')) { skeleton.remove();}} return;} function round(value, precision) { let multiplier = Math.pow(10, precision || 0); return Math.round(value * multiplier) / multiplier;} function formatViews(v) { if (v >= 1e6) return round(v / 1e6, 1) + 'M'; if (v >= 1e3) return round(v / 1e3, 1) + 'K'; return v.toString();} /* Heuristics: locate photo gallery metadata array in initials */ function findPhotoItems(initials, expectedCount, tolerance = 2) { function search(obj, targetLen, depth = 0) { if (depth > 12) return null; if (!obj || typeof obj !== 'object') return null; if (Array.isArray(obj) && obj.length === targetLen && obj.length > 0) { let first = obj[0]; if (first && typeof first === 'object') { let hasPhotoProps = ('pageURL' in first || 'imageURL' in first) && ('titleLocalized' in first || 'title' in first) && ('imgCount' in first || 'views' in first); if (hasPhotoProps) return obj;}} for (let k in obj) { if (obj.hasOwnProperty(k)) { let result = search(obj[k], targetLen, depth + 1); if (result) return result;}} return null;} let exactMatch = search(initials, expectedCount); if (exactMatch) return exactMatch; for (let delta = -tolerance; delta <= tolerance; delta++) { if (delta === 0) continue; let len = expectedCount + delta; if (len <= 0) continue; let match = search(initials, len); if (match) return match;} return null;} /* Generic photo gallery hydration (heuristics-based) */ let photoItemSelector = 'div[class*=\"container-\"] > div[class*=\"wrapper-\"], div[class*=\"container-\"] > div[class*=\"default-\"]'; let photoItems = container.querySelectorAll(photoItemSelector); if (photoItems.length && window._pagetualMasterGallery) { let items = findPhotoItems(initials, photoItems.length, 4); if (items?.length) { let inner = window._pagetualMasterGallery; for (let i = 0; i < photoItems.length && i < items.length; i++) { let ele = photoItems[i]; let data = items[i]; let div = document.createElement('div'); div.innerHTML = inner; let coverLink = div.querySelector('a[class*=\"coverLink-\"]'); if (coverLink && data.pageURL) { coverLink.href = data.pageURL;} let img = div.querySelector('img[class*=\"cover-\"]'); if (img) { img.src = data.imageURL; img.srcset = data.thumbURL; img.alt = data.titleLocalized || '';} let titleLink = div.querySelector('[class*=\"title-\"]'); if (titleLink && data.pageURL) { titleLink.href = data.pageURL; titleLink.textContent = data.titleLocalized || '';} let authorContainer = div.querySelector('[class*=\"author-\"]'); if (authorContainer && data.author) { authorContainer.href = data.author.link; let nameSpan = authorContainer.querySelector('[class*=\"name-\"]'); if (nameSpan) { nameSpan.textContent = data.author.name;}} let avatarImg = div.querySelector('[class*=\"avatar-\"] img'); if (avatarImg && data.author && data.author.img) { avatarImg.src = data.author.img; avatarImg.alt = data.author.name;} let photoSpan = div.querySelector('[class*=\"caption\"][class*=\"label\"]'); if (photoSpan) photoSpan.textContent = data.imgCount; let viewsSpan = div.querySelector('[class*=\"viewsText-\"]'); if (viewsSpan) viewsSpan.textContent = formatViews(data.views) + ' views'; while (ele.firstChild) ele.removeChild(ele.firstChild); while (div.firstChild) ele.appendChild(div.firstChild);} return;}} /* Heuristics: locate video metadata array in initials */ function findVideoProps(obj, depth) { if (depth > 10) return null; if (!obj || typeof obj !== 'object') return null; if (Array.isArray(obj) && obj.length > 0) { let first = obj[0]; if (first && typeof first === 'object' && 'id' in first && 'duration' in first && 'title' in first && 'pageURL' in first && 'views' in first) { return obj;}} for (let k in obj) if (obj.hasOwnProperty(k)) { let r = findVideoProps(obj[k], depth + 1); if (r) return r;} return null;} 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);} /* Generic video page hydration (heuristics-based) */ let videoSelector = 'div[class*=\"thumb-list__item\"]:not([class*=\"loading\"])'; let videoItems = container.querySelectorAll(videoSelector); if (videoItems.length && window._pagetualMasterTemplateVideo) { let props = findVideoProps(initials, 0); if (props?.length) { let inner = window._pagetualMasterTemplateVideo; for (let ele of videoItems) { 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) { if (data.icon === 'friends') { let thumbContainer = div.querySelector('[class*=\"thumb-image-container\"]') || img.parentElement; img.remove(); if (thumbContainer && window._pagetualFriendsOnlyTemplate) { thumbContainer.insertAdjacentHTML('beforeend', window._pagetualFriendsOnlyTemplate);}} else { 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\"] [class*=\"tiny-\"]'); if (durationSpan) durationSpan.textContent = formatDuration(data.duration); 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'; let onVideo = div.querySelector('.thumb-image-container__on-video'); if (onVideo) onVideo.style.zIndex = '20'; if (data.isWatched) { 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'); let tinyBold = 'tiny-bold-' + window._pagetualSuffix; let invert = 'invert-' + window._pagetualSuffix; w.innerHTML = `
Watched
`; 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 = ''; a.appendChild(b);}} while (ele.firstChild) ele.removeChild(ele.firstChild); while (div.firstChild) ele.appendChild(div.firstChild);}}}", + "pageAction": "if(!window._pagetualVideoPreviewAdded){window._pagetualVideoPreviewAdded=true;document.body.addEventListener('mouseenter',(e)=>{let anchor=e.target.closest('a[data-role=\"thumb-link\"]');if(!anchor) return;let trailerUrl=anchor.getAttribute('data-previewvideo');if(!trailerUrl) return;if(anchor._videoElem) return;if(getComputedStyle(anchor).position!=='relative') anchor.style.position='relative';let 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().catch(e=>console.warn('play error:',e));anchor._videoElem=videoElem;},true);document.body.addEventListener('mouseleave',(e)=>{let anchor=e.target.closest('a[data-role=\"thumb-link\"]');if(!anchor) return;let videoElem=anchor._videoElem;if(!videoElem) return;videoElem.pause();videoElem.remove();anchor._videoElem=null;},true);}" } ] diff --git a/Pagetual/version b/Pagetual/version index f96ac067218..e2a9fee008a 100644 --- a/Pagetual/version +++ b/Pagetual/version @@ -1 +1 @@ -105 +109