// ==UserScript== // @name 增加豌豆荚网页版中APP的历史版本下载按钮和相关历史版本app跳转到下载页 // @namespace https://github.com/eaeful/ // @version 0.4 // @description 增加豌豆荚网页版中APP的历史版本下载按钮和相关历史版本app跳转到正常的下载页 // @match https://www.wandoujia.com/apps/*/history_v* // @match https://www.wandoujia.com/apps/* // @match https://m.wandoujia.com/apps/*/history_v* // @match https://m.wandoujia.com/apps/* // @grant none // @license MIT License // @run-at document-end // @downloadURL none // ==/UserScript== (function() { var currentUrl = window.location.href; // 定义匹配第一条件的模式 var pattern1 = /https:\/\/www\.wandoujia\.com\/apps\/(\d+)\/history_v(\d+)/; var match1 = currentUrl.match(pattern1); // 定义匹配第二条件的模式 var pattern2 = /https:\/\/m\.wandoujia\.com\/apps\/(\d+)\/history_v(\d+)/; var match2 = currentUrl.match(pattern2); if (match1) { var appId = match1[1]; var version = match1[2]; // 构建新的跳转URL var newUrl = "https://www.wandoujia.com/mip/apps/" + appId + "/history_v" + version; // 跳转到新的URL window.location.href = newUrl; } else if (match2) { let appId = match2[1]; let version = match2[2]; // 构建新的跳转URL let newUrl = "https://m.wandoujia.com/mip/apps/" + appId + "/history_v" + version; // 跳转到新的URL window.location.href = newUrl; } else { var pattern3 = /https:\/\/www\.wandoujia\.com\/apps\/(\d+)/; var match3 = currentUrl.match(pattern3); var pattern4 = /https:\/\/m\.wandoujia\.com\/apps\/(\d+)/; var match4 = currentUrl.match(pattern4); if (match3) { let appId = match3[1]; // 构建历史版本的新URL var historyUrl = currentUrl + '/history'; var baseUrl = historyUrl.split('?')[0]; // 创建历史版本的链接元素 var historyLink = document.createElement('a'); historyLink.className = 'download install-btn'; historyLink.href = baseUrl; historyLink.target = '_blank'; historyLink.innerText = '历史版本'; // 找到所有的下载容器并添加历史版本链接 var downloadContainers = document.querySelectorAll('div.download-wp'); for (var i = 0; i < downloadContainers.length; i++) { downloadContainers[i].appendChild(historyLink.cloneNode(true)); } } else if (match4) { let appId = match4[1]; // 构建历史版本的新URL let historyUrl = currentUrl + '/history'; let baseUrl = historyUrl.split('?')[0]; // 创建历史版本的链接元素 let historyLink = document.createElement('a'); historyLink.className = 'download install-btn'; historyLink.href = baseUrl; historyLink.target = '_blank'; historyLink.innerText = '历史版本'; // 找到所有的下载容器并添加历史版本链接 let downloadContainers = document.querySelectorAll('div.download-wp'); for (let i = 0; i < downloadContainers.length; i++) { downloadContainers[i].appendChild(historyLink.cloneNode(true)); } } } })();