// ==UserScript== // @name NVIDIA 驱动查询增强 // @namespace http://tampermonkey.net/ // @version 2.2 // @description 修改 NVIDIA 驱动查询参数,获取更多驱动记录 // @author NVDriverHelper // @match https://www.nvidia.com/* // @match https://www.nvidia.cn/* // @match https://gfwsl.geforce.com/* // @grant unsafeWindow // @run-at document-start // @downloadURL none // ==/UserScript== (function() { 'use strict'; var CONFIG = { numberOfResults: 100, driverType: 'grd', forceStandard: false, version: '', release: '' }; console.log('%c[NVDriverHelper] 用户脚本已加载 v2.2', 'color: #76b900; font-weight: bold; font-size: 14px;'); try { var savedConfig = localStorage.getItem('nv-driver-helper-config'); if (savedConfig) { Object.assign(CONFIG, JSON.parse(savedConfig)); console.log('[NVDriverHelper] 加载保存的配置:', CONFIG); } } catch (e) {} function createInterceptorCode(config) { return '(function(){' + 'var CONFIG=' + JSON.stringify(config) + ';' + 'console.log("%c[NVDriverHelper] 拦截器已注入 v2.2","color:#76b900;font-weight:bold");' + 'console.log("[NVDriverHelper] 当前配置:",CONFIG);' + 'function modifyParams(url){' + 'if(!url||typeof url!=="string")return url;' + 'if(!url.includes("DriverManualLookup")&&!url.includes("processFind.aspx")&&!url.includes("AjaxDriverService")&&!url.includes("lookupValueSearch"))return url;' + 'console.log("[NVDriverHelper] 拦截到请求:",url.substring(0,100));' + 'var modified=url;' + 'if(modified.includes("numberOfResults=")){' + 'modified=modified.replace(/numberOfResults=\\d+/,"numberOfResults="+CONFIG.numberOfResults);' + '}else{' + 'modified+="&numberOfResults="+CONFIG.numberOfResults;' + '}' + 'if(CONFIG.driverType==="studio"){' + 'modified=modified.replace(/isWHQL=\\d/g,"isWHQL=0");' + 'modified=modified.replace(/isWHQL=null/g,"isWHQL=0");' + 'modified=modified.replace(/upCRD=\\d/g,"upCRD=1");' + 'modified=modified.replace(/upCRD=null/g,"upCRD=1");' + 'if(!modified.includes("isWHQL="))modified+="&isWHQL=0&upCRD=1";' + 'console.log("[NVDriverHelper] Studio驱动模式: isWHQL=0, upCRD=1");' + '}else{' + 'modified=modified.replace(/isWHQL=\\d/g,"isWHQL=1");' + 'modified=modified.replace(/isWHQL=null/g,"isWHQL=1");' + 'modified=modified.replace(/upCRD=\\d/g,"upCRD=0");' + 'modified=modified.replace(/upCRD=null/g,"upCRD=0");' + 'if(!modified.includes("isWHQL="))modified+="&isWHQL=1&upCRD=0";' + 'console.log("[NVDriverHelper] Game Ready驱动模式: isWHQL=1, upCRD=0");' + '}' + 'if(CONFIG.forceStandard){' + 'modified=modified.replace(/dch=1/g,"dch=0");' + 'console.log("[NVDriverHelper] 强制Standard驱动: dch=0");' + '}' + 'if(CONFIG.version){' + 'if(modified.includes("version=")){' + 'modified=modified.replace(/version=[^&]*/,"version="+CONFIG.version);' + '}else{' + 'modified+="&version="+CONFIG.version;' + '}' + 'console.log("[NVDriverHelper] 指定版本:",CONFIG.version);' + '}' + 'if(CONFIG.release){' + 'if(modified.includes("release=")){' + 'modified=modified.replace(/release=[^&]*/,"release="+CONFIG.release);' + '}else{' + 'modified+="&release="+CONFIG.release;' + '}' + 'console.log("[NVDriverHelper] 指定版本系列:",CONFIG.release);' + '}' + 'console.log("%c[NVDriverHelper] 修改后URL:","color:green",modified.substring(0,200));' + 'return modified;' + '}' + 'var originalXHROpen=XMLHttpRequest.prototype.open;' + 'XMLHttpRequest.prototype.open=function(method,url,async,user,password){' + 'if(url&&typeof url==="string"){' + 'if(url.includes("DriverManualLookup")||url.includes("processFind.aspx")||url.includes("AjaxDriverService")||url.includes("lookupValueSearch")){' + 'url=modifyParams(url);' + '}' + '}' + 'return originalXHROpen.call(this,method,url,async!==false,user,password);' + '};' + 'var originalFetch=window.fetch;' + 'window.fetch=function(url,options){' + 'if(url&&typeof url==="string"){' + 'if(url.includes("DriverManualLookup")||url.includes("processFind.aspx")||url.includes("AjaxDriverService")||url.includes("lookupValueSearch")){' + 'url=modifyParams(url);' + '}' + '}else if(url&&url.url){' + 'var urlStr=url.url;' + 'if(urlStr.includes("DriverManualLookup")||urlStr.includes("processFind.aspx")||urlStr.includes("AjaxDriverService")||urlStr.includes("lookupValueSearch")){' + 'var modifiedUrl=modifyParams(urlStr);' + 'if(modifiedUrl!==urlStr){' + 'url=new Request(modifiedUrl,{method:url.method,headers:url.headers,body:url.body,mode:url.mode,credentials:url.credentials,cache:url.cache,redirect:url.redirect,referrer:url.referrer});' + '}' + '}' + '}' + 'return originalFetch.call(this,url,options);' + '};' + 'var originalOpen=window.open;' + 'window.open=function(url,target,features){' + 'if(url&&typeof url==="string"){' + 'if(url.includes("processFind.aspx")||url.includes("driverResults")){' + 'url=modifyParams(url);' + '}' + '}' + 'return originalOpen.call(this,url,target,features);' + '};' + 'document.addEventListener("click",function(e){' + 'var target=e.target;' + 'while(target&&target.tagName!=="A")target=target.parentElement;' + 'if(target&&target.href){' + 'if(target.href.includes("processFind.aspx")||target.href.includes("driverResults")){' + 'target.href=modifyParams(target.href);' + '}' + '}' + '},true);' + 'var originalSubmit=HTMLFormElement.prototype.submit;' + 'HTMLFormElement.prototype.submit=function(){' + 'if(this.action&&(this.action.includes("processFind.aspx")||this.action.includes("driverResults"))){' + 'this.action=modifyParams(this.action);' + '}' + 'return originalSubmit.call(this);' + '};' + 'console.log("%c[NVDriverHelper] 所有拦截器已启用!","color:#76b900;font-size:14px");' + '})();'; } function injectInterceptor(config) { var script = document.createElement('script'); script.id = 'nv-driver-helper-interceptor'; script.textContent = createInterceptorCode(config); var oldScript = document.getElementById('nv-driver-helper-interceptor'); if (oldScript) oldScript.remove(); (document.head || document.documentElement).appendChild(script); script.remove(); } injectInterceptor(CONFIG); function modifyUrlParams(url) { if (!url || typeof url !== 'string') return url; var modified = url; if (modified.includes('numberOfResults=')) { modified = modified.replace(/numberOfResults=\d+/, 'numberOfResults=' + CONFIG.numberOfResults); } else { modified += '&numberOfResults=' + CONFIG.numberOfResults; } if (CONFIG.driverType === 'studio') { modified = modified.replace(/isWHQL=\d/, 'isWHQL=0'); modified = modified.replace(/isWHQL=null/, 'isWHQL=0'); modified = modified.replace(/upCRD=\d/, 'upCRD=1'); modified = modified.replace(/upCRD=null/, 'upCRD=1'); if (!modified.includes('isWHQL=')) { modified += '&isWHQL=0&upCRD=1'; } } else { modified = modified.replace(/isWHQL=\d/, 'isWHQL=1'); modified = modified.replace(/isWHQL=null/, 'isWHQL=1'); modified = modified.replace(/upCRD=\d/, 'upCRD=0'); modified = modified.replace(/upCRD=null/, 'upCRD=0'); if (!modified.includes('isWHQL=')) { modified += '&isWHQL=1&upCRD=0'; } } if (CONFIG.forceStandard) { modified = modified.replace(/dch=1/g, 'dch=0'); } if (CONFIG.version) { if (modified.includes('version=')) { modified = modified.replace(/version=[^&]*/, 'version=' + CONFIG.version); } else { modified += '&version=' + CONFIG.version; } } if (CONFIG.release) { if (modified.includes('release=')) { modified = modified.replace(/release=[^&]*/, 'release=' + CONFIG.release); } else { modified += '&release=' + CONFIG.release; } } return modified; } var originalXHROpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url, async, user, password) { if (url && typeof url === 'string') { if (url.includes('DriverManualLookup') || url.includes('processFind.aspx') || url.includes('AjaxDriverService')) { url = modifyUrlParams(url); console.log('[NVDriverHelper] XHR 修改:', url.substring(0, 100)); } } return originalXHROpen.call(this, method, url, async !== false, user, password); }; var originalFetch = window.fetch; window.fetch = function(url, options) { if (url && typeof url === 'string') { if (url.includes('DriverManualLookup') || url.includes('processFind.aspx') || url.includes('AjaxDriverService')) { url = modifyUrlParams(url); console.log('[NVDriverHelper] Fetch 修改:', url.substring(0, 100)); } } return originalFetch.call(this, url, options); }; function createPanel() { if (document.getElementById('nv-driver-helper-panel')) return; var panel = document.createElement('div'); panel.id = 'nv-driver-helper-panel'; var html = '' + '' + '

NVIDIA 驱动增强 v2.2

' + '
' + '' + '' + '' + '' + '' + '' + '
配置已应用! 现在可以搜索驱动了。
' + '
使用方法:
1. 配置参数并点击"应用配置"
2. 在 NVIDIA 页面搜索驱动
3. 查看更多驱动记录
' + '
'; panel.innerHTML = html; document.body.appendChild(panel); panel.querySelector('.minimize').addEventListener('click', function() { panel.classList.toggle('minimized'); panel.querySelector('.minimize').textContent = panel.classList.contains('minimized') ? '+' : '−'; }); var saveConfig = function() { CONFIG.numberOfResults = parseInt(document.getElementById('hdv-numResults').value) || 100; CONFIG.driverType = document.getElementById('hdv-driverType').value; CONFIG.forceStandard = document.getElementById('hdv-forceStandard').checked; CONFIG.version = document.getElementById('hdv-version').value.trim(); CONFIG.release = document.getElementById('hdv-release').value.trim(); localStorage.setItem('nv-driver-helper-config', JSON.stringify(CONFIG)); console.log('[NVDriverHelper] 配置已保存:', CONFIG); }; document.getElementById('hdv-apply').addEventListener('click', function() { saveConfig(); injectInterceptor(CONFIG); document.getElementById('hdv-success').style.display = 'block'; setTimeout(function() { document.getElementById('hdv-success').style.display = 'none'; }, 3000); }); panel.querySelectorAll('input, select').forEach(function(el) { el.addEventListener('change', saveConfig); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', createPanel); } else { createPanel(); } console.log('%c[NVDriverHelper] 脚本初始化完成', 'color: #76b900;'); })();