九色-优化

91porny(九色)视频宽屏-直接下载-增加作者栏

// ==UserScript==
// @name         九色-优化
// @version      1.1.0
// @namespace    https://sleazyfork.org/zh-CN/users/1461640-%E6%98%9F%E5%AE%BF%E8%80%81%E9%AD%94
// @author       星宿老魔
// @description  91porny(九色)视频宽屏-直接下载-增加作者栏
// @match        https://91porny.com/*
// @match        https://*.jiuse.vip/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=91porny.com
// @license      MIT
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function(){"use strict";const e=class _StyleInjector{static init(){void 0;this.addStyles()}static addStyles(){
const e=document.createElement("style");e.textContent=this.cssRules;document.head.appendChild(e);void 0}}
;e.cssRules=`\n    .videoPlayContainer {\n      width: 100% !important;\n      max-width: 100% !important;\n      margin: 0 auto !important;\n      margin-top: 0 !important;\n      padding-top: 0 !important;\n    }\n    .video-js {\n      width: 100% !important;\n      max-width: 100% !important;\n    }\n    .row .col-100 {\n      width: 100% !important;\n      max-width: 100% !important;\n      flex-basis: 100% !important;\n      margin: 0 !important;\n      padding: 0 10px !important;\n      margin-top: 0 !important;\n      padding-top: 0 !important;\n    }\n    .row {\n      margin-top: 0 !important;\n      padding-top: 0 !important;\n    }\n    .row .side.col-40.col-md-50 {\n      display: none;\n    }\n    .videoPlayContainer .scale {\n      padding-bottom: 0 !important;\n      height: auto !important;\n      min-height: 0 !important;\n      aspect-ratio: unset !important;\n      margin-top: 0 !important;\n      padding-top: 0 !important;\n    }\n    .videoPlayContainer .video-js {\n      position: relative !important;\n      top: 0 !important;\n      left: 0 !important;\n    }\n    .videoPlayContainer,\n    .videoPlayContainer > *,\n    .col-100 {\n      margin-top: 0 !important;\n      padding-top: 0 !important;\n    }\n    body .container .row:first-child {\n      margin-top: 0 !important;\n      padding-top: 0 !important;\n    }\n    \n    .rec-tabs-container {\n        display: flex;\n        gap: 10px;\n        margin-bottom: 10px;\n    }\n    .rec-tab-button {\n        background-color: #333;\n        color: #fff;\n        border: 1px solid #555;\n        padding: 8px 15px;\n        cursor: pointer;\n        border-radius: 5px;\n        font-size: 16px;\n        font-weight: bold;\n    }\n    .rec-tab-button.active {\n        background-color: #f0ad4e;\n        color: #000;\n        border-color: #f0ad4e;\n    }\n    .rec-tab-button:not(.active):hover {\n        background-color: #444;\n    }\n    #recommended-videos-container, #author-videos-container {\n        flex-wrap: wrap;\n    }\n    .d9867a703dd9335a77b9f88459aa7bff {\n      display: none !important;\n    }\n    \n    /* 广告拦截CSS - 仅针对特定广告容器 */\n    .aa9965ce0d851e635fa7ec1dbf56d965,\n    #po-s6 {\n      display: none !important;\n      visibility: hidden !important;\n    }\n  `
;let t=e;const CONFIG={debounceDelay:250,selectors:{videoContainer:".videoPlayContainer",videoElement:".video-js",
videoColumn:".left.col-60.offset-md-10.col-md-40, .left.col-md-40.offset-md-10.col-60"}};class WideScreen{static init(){
void 0;this.setWideScreenMode();this.setupResizeListener()}static setWideScreenMode(){
const e=document.querySelector(CONFIG.selectors.videoContainer)
;const t=document.querySelector(CONFIG.selectors.videoElement);if(!e&&!t){void 0;return}this.applyVideoColumnClasses()
;this.calculateVideoHeight(e,t);void 0}static applyVideoColumnClasses(){
const e=document.querySelector(CONFIG.selectors.videoColumn);if(e){
e.classList.remove("col-60","offset-md-10","col-md-40");e.classList.add("col-100")}}static calculateVideoHeight(e,t){
if(t){const n=16/9;const o=e?e.offsetWidth:window.innerWidth;const i=o/n;t.style.height=`${i}px`}}
static setupResizeListener(){window.addEventListener("resize",()=>{
const e=document.querySelector(CONFIG.selectors.videoContainer)
;const t=document.querySelector(CONFIG.selectors.videoElement);this.calculateVideoHeight(e,t)})}}
class VideoRecommendation{static init(){void 0;this.modifyVideoRecommendations()}static modifyVideoRecommendations(){
if(document.getElementById("rec-tabs-container"))return
;const e=Array.from(document.querySelectorAll("h5.container-title")).find(e=>"视频推荐"===e.textContent?.trim())
;if(!e)return;const t=e.parentElement;const n=t.nextElementSibling;if(!n||!n.classList.contains("row"))return
;n.id="recommended-videos-container";n.style.display="flex";const o=this.createAuthorInfoContainer()
;n.parentNode?.insertBefore(o,n);const i=this.createAuthorVideosContainer();o.parentNode?.insertBefore(i,o.nextSibling)
;const{recommendedBtn:d,authorBtn:s,buttonContainer:a}=this.createTabButtons();t.innerHTML="";t.appendChild(a)
;this.setupTabEvents(d,s,n,i,o)}static createAuthorInfoContainer(){const e=document.createElement("div")
;e.id="author-info-container";e.style.display="none";return e}static createAuthorVideosContainer(){
const e=document.createElement("div");e.id="author-videos-container";e.className="row";e.style.display="none";return e}
static createTabButtons(){const e=document.createElement("button");e.textContent="视频推荐"
;e.className="rec-tab-button active";const t=document.createElement("button");t.textContent="作者视频"
;t.className="rec-tab-button";const n=document.createElement("div");n.id="rec-tabs-container"
;n.className="rec-tabs-container";n.appendChild(e);n.appendChild(t);return{recommendedBtn:e,authorBtn:t,
buttonContainer:n}}static setupTabEvents(e,t,n,o,i){e.addEventListener("click",()=>{e.classList.add("active")
;t.classList.remove("active");n.style.display="flex";o.style.display="none";i.style.display="none"})
;t.addEventListener("click",()=>{t.classList.add("active");e.classList.remove("active");n.style.display="none"
;o.style.display="flex";i.style.display="block";if(0===o.children.length){
const e=document.querySelector('.d-flex.justify-content-between a[href*="/author/"]')
;if(e)this.fetchAuthorInfoAndVideos(e.href,o,i);else o.innerHTML='<p style="color: white; padding: 20px;">未找到当前视频的作者信息。</p>'
}})}static fetchAuthorInfoAndVideos(e,t,n){t.innerHTML='<p style="color: white; padding: 20px;">正在加载作者视频...</p>'
;n.innerHTML="";fetch(e).then(e=>e.text()).then(o=>{const i=new DOMParser;const d=i.parseFromString(o,"text/html")
;const s=Array.from(d.querySelectorAll("p, h1, h2, h3, h4, h5")).find(e=>e.textContent?.includes("共计")&&e.textContent?.includes("视频"))
;if(s){const t=document.createElement("a");t.href=e;t.target="_blank";let o=s.textContent?.trim()||""
;let i=o.split(",")[0];if(i===o)i=o.split(",")[0];t.textContent=i;t.title="点击跳转作者主页";t.style.color="#f0ad4e"
;t.style.display="block";t.style.marginBottom="10px";n.appendChild(t)}const a=d.querySelectorAll(".colVideoList")
;t.innerHTML="";if(a.length>0)a.forEach(e=>{t.appendChild(e)
});else t.innerHTML='<p style="color: white; padding: 20px;">该作者没有其他视频。</p>'}).catch(e=>{void 0
;t.innerHTML='<p style="color: white; padding: 20px;">加载作者视频失败。</p>'})}}const n=class _AdBlocker{static init(){void 0
;if(!this.isInitialized){this.setupAdWatcher();this.isInitialized=true}this.removeAuthorComments()}
static removeAuthorComments(){const e=document.querySelector(".aa9965ce0d851e635fa7ec1dbf56d965");if(e){e.remove()
;void 0}const t=document.getElementById("po-s6");if(t){t.remove();void 0}
const n=document.querySelectorAll('div[class*="aa9965ce0d851e635fa7ec1dbf56d965"]');n.forEach(e=>{e.remove();void 0})}
static setupAdWatcher(){const startObserver=()=>{if(!document.body){
if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",startObserver);else setTimeout(startObserver,100)
;return}const observer=new MutationObserver(e=>{e.forEach(e=>{if(e.addedNodes.length>0)e.addedNodes.forEach(e=>{
if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(this.isAdElement(t)){t.remove();void 0}
const n=t.querySelectorAll(".aa9965ce0d851e635fa7ec1dbf56d965, #po-s6");n.forEach(e=>{e.remove();void 0})}})})})
;observer.observe(document.body,{childList:true,subtree:true});void 0};startObserver()}static isAdElement(e){
const t=e.className||"";const n=e.id||"";return t.includes("aa9965ce0d851e635fa7ec1dbf56d965")||"po-s6"===n}
static checkAndRemoveAds(){this.removeAuthorComments()}};n.isInitialized=false;let o=n;function debounce(e,t){let n
;return function executedFunction(...o){const later=()=>{clearTimeout(n);e(...o)};clearTimeout(n)
;n=window.setTimeout(later,t)}}const i=class _DOMObserver{static init(){void 0;this.setupDocumentListeners()
;this.setupMutationObserver()}static setupDocumentListeners(){const e=500;const runUpdates=()=>{
WideScreen.setWideScreenMode();VideoRecommendation.modifyVideoRecommendations();o.checkAndRemoveAds()}
;if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",()=>setTimeout(runUpdates,e));else setTimeout(runUpdates,e)
;document.addEventListener("load",e=>{const t=e.target
;if("VIDEO"===t.tagName||"IFRAME"===t.tagName)WideScreen.setWideScreenMode()},true)
;window.addEventListener("load",runUpdates)}static setupMutationObserver(){const runUpdates=()=>{
WideScreen.setWideScreenMode();VideoRecommendation.modifyVideoRecommendations();o.checkAndRemoveAds()}
;const e=debounce(runUpdates,CONFIG.debounceDelay);this.observer=new MutationObserver(t=>{let n=false;t.forEach(e=>{
if(e.addedNodes.length>0)e.addedNodes.forEach(e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e
;if(t.matches&&(t.matches(".videoPlayContainer")||t.matches(".video-js")||t.matches('[class*="recommend"]')||t.matches('[class*="video"]')||"VIDEO"===t.tagName||"IFRAME"===t.tagName))n=true
}})});if(n)e()});if(document.body){this.observer.observe(document.body,{childList:true,subtree:true});void 0}else{
const startWhenReady=()=>{if(document.body){this.observer?.observe(document.body,{childList:true,subtree:true});void 0
}else setTimeout(startWhenReady,100)}
;if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",startWhenReady);else startWhenReady()}}
static destroy(){if(this.observer){this.observer.disconnect();this.observer=null}}};i.observer=null;let d=i
;class DirectDownload{static init(){void 0;setTimeout(()=>{this.enhanceDownloadTab()},1500)}static enhanceDownloadTab(){
try{const e=document.querySelector('a[href="#videoShowTabDownload"]');if(!e){void 0;return}
const t=document.querySelector("button.btn-primary");if(!t||!t.textContent?.includes("点击下载视频")){void 0;return}void 0
;this.copyDownloadFunction(e,t);void 0}catch(e){void 0}}static copyDownloadFunction(e,t){e.addEventListener("click",e=>{
e.preventDefault();e.stopPropagation();void 0;t.click();void 0});e.addEventListener("mouseenter",()=>{
e.style.backgroundColor="#007bff";e.style.color="white"});e.addEventListener("mouseleave",()=>{
e.style.backgroundColor="";e.style.color=""})}static addDownloadIndicator(e){}}void 0;t.init();function init(){o.init()
;WideScreen.init();VideoRecommendation.init();d.init();DirectDownload.init();void 0;void 0}init()})();