From 202ee82977d46f2271dab57feb8cb82c58378de2 Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Thu, 27 Jun 2024 21:30:26 +0800 Subject: [PATCH 01/12] add personal game completion background to gamelist --- psnineplus.js | 150 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 116 insertions(+), 34 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index 0908b25..4fb1655 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -397,7 +397,7 @@ $('body,html').animate({ scrollTop: document.body.clientHeight, }, - 500); + 500); }).css({ cursor: 'pointer', }); @@ -410,9 +410,31 @@ document.head.appendChild(nightModeStyle); } - /* 游戏列表添加按难度排列按钮 */ + /* + 1.游戏列表添加按难度排列按钮 + 2.游戏列表根据已记录的完成度添加染色 + 3.TODO:游戏列表隐藏已经 100% 的游戏(需要添加用户可见的开关) + */ const hdElement = document.querySelector('.hd'); if (hdElement && hdElement.textContent.trim() === '游戏列表') { + + const tdElements = document.querySelectorAll('table.list tbody > tr'); + + // 添加完成度染色 + + const platinumBackground = 'background-color: #d0f6ff;background-image: linear-gradient(90deg, #c7fffd 0%, #ffffff 60%);' + const goldBackground = 'background-color: #e5ffe7;background-image: linear-gradient(90deg, #daffde 0%, #ffffff 60%);' + const personalGameCompletions = GM_getValue('personalGameCompletions', []) + tdElements.forEach((tr) => { + const gameID = tr.getAttribute('id') || 0; + const thisGameCompletion = personalGameCompletions.find(item => item[0] == gameID); + if (thisGameCompletion) { + if (thisGameCompletion[1] == 100 && thisGameCompletion[2] == true) { tr.setAttribute('style', platinumBackground); } + if (thisGameCompletion[1] == 100 && thisGameCompletion[2] == false) { tr.setAttribute('style', goldBackground); } + } + }) + + // 创建新的 span 元素 const spanElement = document.createElement('span'); spanElement.className = 'btn'; @@ -441,11 +463,11 @@ // 为 span 元素添加点击排序功能 spanElement.addEventListener('click', () => { - const tdElements = document.querySelectorAll('table.list tbody > tr'); - const tdArray = Array.from(tdElements).map((td) => { - const valueElement = td.querySelector('td.twoge > em'); + + const tdArray = Array.from(tdElements).map((tr) => { + const valueElement = tr.querySelector('td.twoge > em'); const value = valueElement ? parseFloat(valueElement.textContent) : null; - return { td, value }; + return { tr, value }; }); // 根据当前的排序顺序进行排序 @@ -458,7 +480,7 @@ const tbody = document.querySelector('table.list tbody'); tbody.innerHTML = ''; tdArray.forEach((item) => { - tbody.appendChild(item.td); + tbody.appendChild(item.tr); }); // 切换排序顺序 @@ -527,9 +549,66 @@ }`, ); + /* + 在 LocatStorage 中保存个人游戏完成度函数 + 添加于 /psnid\/[A-Za-z0-9_-]+\/?$/ 页面,以及该页自动翻页函数内部 + */ + + const savePersonalGameCompletions = (configifneeded) => { + + // if GM_setValue && GM_getValue is enabled + + let thisFeatureEnabled = configifneeded || true && (typeof GM_setValue === 'function' && typeof GM_getValue === 'function') + + if (thisFeatureEnabled) { + + // 获得当前页的游戏完成度 + const tdElements = document.querySelectorAll('table.list tbody > tr'); + const personalGameCompletions = Array.from(tdElements).map((tr) => { + const completionElement = tr.querySelector('div.progress > div') + const completion = completionElement ? parseFloat(completionElement.textContent) : 0 + const platinumElement = tr.querySelector('span.text-platinum') + const platinum = platinumElement ? platinumElement.textContent == '白1' : false + const gameIDElement = tr.querySelector('a') + const gameID = gameIDElement.href.match(/\/psngame\/(\d+)/)[1] + + return [gameID, completion, platinum] + }) + + // 读取已保存的历史 + let history = GM_getValue('personalGameCompletions', []) + + // 用当前覆盖历史 + personalGameCompletions.forEach((currentItem) => { + const index = history.findIndex(historyItem => historyItem[0] === currentItem[0]); + if (index !== -1) { + history[index] = currentItem; + } else { + history.push(currentItem); + } + }); + + // 保存更新后的历史记录 + GM_setValue('personalGameCompletions', history); + console.log(GM_getValue('personalGameCompletions')) + return true + } else { + return false + } + } + + // 在个人页面或个人游戏列表页更新数据 + if ( + /psnid\/[A-Za-z0-9_-]+\/?$/.test(window.location.href) || /psnid\/[A-Za-z0-9_-]+\/psngame\/?/.test(window.location.href) + ) { + savePersonalGameCompletions() + } + + + if ( /psnid\/[A-Za-z0-9_-]+\/?$/.test(window.location.href) - && $('tbody').length > 2 + && $('tbody').length > 2 ) { const windowLocationHref = window.location.href.replace(/\/$/g, ''); // 功能0-7:个人主页下显示所有游戏 @@ -541,9 +620,9 @@ $(window).scroll(function () { if ( $(this).scrollTop() + $(window).height() + 700 - >= $(document).height() - && $(this).scrollTop() > 700 - && isbool2 === true + >= $(document).height() + && $(this).scrollTop() > 700 + && isbool2 === true ) { isbool2 = false; const gamePage = `${windowLocationHref}/psngame?page=${gamePageIndex}`; @@ -559,6 +638,9 @@ $('tbody > tr:last').after(nextGameContent); isbool2 = true; gamePageIndex += 1; + + // 同步更新个人游戏完成度 + savePersonalGameCompletions() } else { $('#loadingMessage').text('没有更多游戏了...'); } @@ -659,7 +741,7 @@ if ( /(gene|trade|topic)\//.test(window.location.href) - && !/comment/.test(window.location.href) + && !/comment/.test(window.location.href) ) { // 获取楼主ID const authorId = $('.title2').text(); @@ -876,16 +958,16 @@ $('div.meta').each((index, element) => { const replyCount = $(element).text().split(/(\d+)/); if (Number(replyCount[replyCount.length - 2]) > settings.hotTagThreshold - && replyCount[replyCount.length - 1].match('评论|答案|回复') - && replyCount[replyCount.length - 1].match('评论|答案|回复').index > -1 - && $(element).children('a#hot').length === 0 + && replyCount[replyCount.length - 1].match('评论|答案|回复') + && replyCount[replyCount.length - 1].match('评论|答案|回复').index > -1 + && $(element).children('a#hot').length === 0 ) { const tagBackgroundColor = $('body.bg').css('background-color'); $(element) .append(` 🔥热门 `); + };color: rgb(255, 255, 255);">🔥热门 `); } }); }; @@ -1096,12 +1178,12 @@ const filterBlockWorld = () => { const windowHref = window.location.href; if (windowHref.indexOf('gene') > -1 // 机因回复 - || windowHref.indexOf('topic') > -1 // 主帖回复 - || windowHref.indexOf('trophy') > -1 // 奖杯TIPS - || windowHref.indexOf('qa') > -1 // 问答回复 - || windowHref.indexOf('trade') > -1 // 交易回复 - || windowHref.match(/\/battle\/[1-9][0-9]+/) !== null // 约战回复 - || windowHref.match(/\/psnid\/[^/]+\/comment/) !== null // 个人主页留言 + || windowHref.indexOf('topic') > -1 // 主帖回复 + || windowHref.indexOf('trophy') > -1 // 奖杯TIPS + || windowHref.indexOf('qa') > -1 // 问答回复 + || windowHref.indexOf('trade') > -1 // 交易回复 + || windowHref.match(/\/battle\/[1-9][0-9]+/) !== null // 约战回复 + || windowHref.match(/\/psnid\/[^/]+\/comment/) !== null // 个人主页留言 ) { FilterWordRegular('div.ml64>div.content.pb10'); } @@ -1350,13 +1432,13 @@ let isbool = true; // 触发开关,防止多次调用事件 let autoPagingLimitCount = 0; $(window).scroll(function () { - // 当内容滚动到底部时加载新的内容 + // 当内容滚动到底部时加载新的内容 if ( $(this).scrollTop() + $(window).height() + 700 - >= $(document).height() - && $(this).scrollTop() > 700 - && isbool === true - && autoPagingLimitCount < settings.autoPaging + >= $(document).height() + && $(this).scrollTop() > 700 + && isbool === true + && autoPagingLimitCount < settings.autoPaging ) { isbool = false; // 获取下一页页码和链接 @@ -1669,7 +1751,7 @@ }; const CNY = price.map((item) => ( Number(item.replace(regionCurrency[region][0], '')) - * regionCurrency[region][1] + * regionCurrency[region][1] )); // 整块增加的价格表示 const addCNYPriceBlock = [ @@ -1895,7 +1977,7 @@ // 页面:数折 > 商品页 if ( /\/dd\//.test(window.location.href) - || /game\/[0-9]+\/dd$/.test(window.location.href) + || /game\/[0-9]+\/dd$/.test(window.location.href) ) { repeatUntilSuccessful(() => { if (httpCSSFixed()) { @@ -2297,9 +2379,9 @@ // 功能3-1:游戏奖杯界面可视化 if ( /psngame\//.test(window.location.href) - && /^(?!.*comment|.*rank|.*battle|.*gamelist|.*topic|.*qa)/.test( - window.location.href, - ) + && /^(?!.*comment|.*rank|.*battle|.*gamelist|.*topic|.*qa)/.test( + window.location.href, + ) ) { $('.box.pd10').append('
'); repeatUntilSuccessful(() => { @@ -2393,7 +2475,7 @@ // 进入游戏页默认查看我自己的奖杯 if ( window.location.href.match(/psngame\/\d+($|\/$)|(#\d+($|\/$))/) - && !/psnid/.test(window.location.href) + && !/psnid/.test(window.location.href) ) { // 检查游戏页 window.onpageshow = (e) => { @@ -3078,7 +3160,7 @@ return ( startOfYear.getTime() + (-((startOfYear.getUTCDay() || 7) - 1) - + (7 * (week - 1) + (day - 1))) * 86400000/* milliseconds of a day */ + + (7 * (week - 1) + (day - 1))) * 86400000/* milliseconds of a day */ ); }; const weekDifference = (date1, date2) => { From 28b4b6bd7ae0f224a946c8d3a688191c9c737488 Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Thu, 27 Jun 2024 21:40:26 +0800 Subject: [PATCH 02/12] clear --- psnineplus.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index 4fb1655..17d705a 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -421,10 +421,11 @@ const tdElements = document.querySelectorAll('table.list tbody > tr'); // 添加完成度染色 - const platinumBackground = 'background-color: #d0f6ff;background-image: linear-gradient(90deg, #c7fffd 0%, #ffffff 60%);' const goldBackground = 'background-color: #e5ffe7;background-image: linear-gradient(90deg, #daffde 0%, #ffffff 60%);' const personalGameCompletions = GM_getValue('personalGameCompletions', []) + + // 根据已保存的完成度添加染色 tdElements.forEach((tr) => { const gameID = tr.getAttribute('id') || 0; const thisGameCompletion = personalGameCompletions.find(item => item[0] == gameID); @@ -434,7 +435,6 @@ } }) - // 创建新的 span 元素 const spanElement = document.createElement('span'); spanElement.className = 'btn'; @@ -557,11 +557,9 @@ const savePersonalGameCompletions = (configifneeded) => { // if GM_setValue && GM_getValue is enabled - let thisFeatureEnabled = configifneeded || true && (typeof GM_setValue === 'function' && typeof GM_getValue === 'function') if (thisFeatureEnabled) { - // 获得当前页的游戏完成度 const tdElements = document.querySelectorAll('table.list tbody > tr'); const personalGameCompletions = Array.from(tdElements).map((tr) => { @@ -571,7 +569,6 @@ const platinum = platinumElement ? platinumElement.textContent == '白1' : false const gameIDElement = tr.querySelector('a') const gameID = gameIDElement.href.match(/\/psngame\/(\d+)/)[1] - return [gameID, completion, platinum] }) @@ -590,7 +587,7 @@ // 保存更新后的历史记录 GM_setValue('personalGameCompletions', history); - console.log(GM_getValue('personalGameCompletions')) + // console.log(GM_getValue('personalGameCompletions')) return true } else { return false @@ -605,7 +602,6 @@ } - if ( /psnid\/[A-Za-z0-9_-]+\/?$/.test(window.location.href) && $('tbody').length > 2 From 23d5e47199b89ce2b3248e68512cfc1f24abf266 Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Thu, 27 Jun 2024 21:42:40 +0800 Subject: [PATCH 03/12] clear --- psnineplus.js | 1 - 1 file changed, 1 deletion(-) diff --git a/psnineplus.js b/psnineplus.js index 17d705a..8343421 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -463,7 +463,6 @@ // 为 span 元素添加点击排序功能 spanElement.addEventListener('click', () => { - const tdArray = Array.from(tdElements).map((tr) => { const valueElement = tr.querySelector('td.twoge > em'); const value = valueElement ? parseFloat(valueElement.textContent) : null; From f1c60820d1f032ced3ee07445b1f1eae9105b810 Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Sun, 30 Jun 2024 00:18:13 +0800 Subject: [PATCH 04/12] lint --- psnineplus.js | 60 ++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index 8343421..1baa43d 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -397,7 +397,7 @@ $('body,html').animate({ scrollTop: document.body.clientHeight, }, - 500); + 500); }).css({ cursor: 'pointer', }); @@ -410,30 +410,29 @@ document.head.appendChild(nightModeStyle); } - /* - 1.游戏列表添加按难度排列按钮 + /* + 1.游戏列表添加按难度排列按钮 2.游戏列表根据已记录的完成度添加染色 3.TODO:游戏列表隐藏已经 100% 的游戏(需要添加用户可见的开关) */ const hdElement = document.querySelector('.hd'); if (hdElement && hdElement.textContent.trim() === '游戏列表') { - const tdElements = document.querySelectorAll('table.list tbody > tr'); // 添加完成度染色 - const platinumBackground = 'background-color: #d0f6ff;background-image: linear-gradient(90deg, #c7fffd 0%, #ffffff 60%);' - const goldBackground = 'background-color: #e5ffe7;background-image: linear-gradient(90deg, #daffde 0%, #ffffff 60%);' - const personalGameCompletions = GM_getValue('personalGameCompletions', []) + const platinumBackground = 'background-color: #d0f6ff;background-image: linear-gradient(90deg, #c7fffd 0%, #ffffff 60%);'; + const goldBackground = 'background-color: #e5ffe7;background-image: linear-gradient(90deg, #daffde 0%, #ffffff 60%);'; + const personalGameCompletions = GM_getValue('personalGameCompletions', []); // 根据已保存的完成度添加染色 tdElements.forEach((tr) => { const gameID = tr.getAttribute('id') || 0; - const thisGameCompletion = personalGameCompletions.find(item => item[0] == gameID); + const thisGameCompletion = personalGameCompletions.find((item) => item[0] === gameID); if (thisGameCompletion) { - if (thisGameCompletion[1] == 100 && thisGameCompletion[2] == true) { tr.setAttribute('style', platinumBackground); } - if (thisGameCompletion[1] == 100 && thisGameCompletion[2] == false) { tr.setAttribute('style', goldBackground); } + if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === true) { tr.setAttribute('style', platinumBackground); } + if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === false) { tr.setAttribute('style', goldBackground); } } - }) + }); // 创建新的 span 元素 const spanElement = document.createElement('span'); @@ -548,35 +547,34 @@ }`, ); - /* + /* 在 LocatStorage 中保存个人游戏完成度函数 添加于 /psnid\/[A-Za-z0-9_-]+\/?$/ 页面,以及该页自动翻页函数内部 */ const savePersonalGameCompletions = (configifneeded) => { - // if GM_setValue && GM_getValue is enabled - let thisFeatureEnabled = configifneeded || true && (typeof GM_setValue === 'function' && typeof GM_getValue === 'function') + const thisFeatureEnabled = (configifneeded || true) && (typeof GM_setValue === 'function' && typeof GM_getValue === 'function'); if (thisFeatureEnabled) { // 获得当前页的游戏完成度 const tdElements = document.querySelectorAll('table.list tbody > tr'); const personalGameCompletions = Array.from(tdElements).map((tr) => { - const completionElement = tr.querySelector('div.progress > div') - const completion = completionElement ? parseFloat(completionElement.textContent) : 0 - const platinumElement = tr.querySelector('span.text-platinum') - const platinum = platinumElement ? platinumElement.textContent == '白1' : false - const gameIDElement = tr.querySelector('a') - const gameID = gameIDElement.href.match(/\/psngame\/(\d+)/)[1] - return [gameID, completion, platinum] - }) + const completionElement = tr.querySelector('div.progress > div'); + const completion = completionElement ? parseFloat(completionElement.textContent) : 0; + const platinumElement = tr.querySelector('span.text-platinum'); + const platinum = platinumElement ? platinumElement.textContent === '白1' : false; + const gameIDElement = tr.querySelector('a'); + const gameID = gameIDElement.href.match(/\/psngame\/(\d+)/)[1]; + return [gameID, completion, platinum]; + }); // 读取已保存的历史 - let history = GM_getValue('personalGameCompletions', []) + const history = GM_getValue('personalGameCompletions', []); // 用当前覆盖历史 personalGameCompletions.forEach((currentItem) => { - const index = history.findIndex(historyItem => historyItem[0] === currentItem[0]); + const index = history.findIndex((historyItem) => historyItem[0] === currentItem[0]); if (index !== -1) { history[index] = currentItem; } else { @@ -587,20 +585,18 @@ // 保存更新后的历史记录 GM_setValue('personalGameCompletions', history); // console.log(GM_getValue('personalGameCompletions')) - return true - } else { - return false + return true; } - } + return false; + }; // 在个人页面或个人游戏列表页更新数据 if ( /psnid\/[A-Za-z0-9_-]+\/?$/.test(window.location.href) || /psnid\/[A-Za-z0-9_-]+\/psngame\/?/.test(window.location.href) ) { - savePersonalGameCompletions() + savePersonalGameCompletions(); } - if ( /psnid\/[A-Za-z0-9_-]+\/?$/.test(window.location.href) && $('tbody').length > 2 @@ -635,7 +631,7 @@ gamePageIndex += 1; // 同步更新个人游戏完成度 - savePersonalGameCompletions() + savePersonalGameCompletions(); } else { $('#loadingMessage').text('没有更多游戏了...'); } @@ -962,7 +958,7 @@ .append(` 🔥热门 `); + };color: rgb(255, 255, 255);">🔥热门 `); } }); }; From 876b4727c420e50978e799510abb37a8c70e48b5 Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Fri, 5 Jul 2024 23:26:07 +0800 Subject: [PATCH 05/12] add night style && add progress-badge --- psnineplus.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index 1baa43d..3af01cc 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -417,11 +417,51 @@ */ const hdElement = document.querySelector('.hd'); if (hdElement && hdElement.textContent.trim() === '游戏列表') { + // 添加自定义的 CSS 类 + GM_addStyle(` + span.completion-badge { + background-color: rgb(5 96 175); + font-size: 11px; + color: white; + border-radius: 2px; + padding: 2px 6px; + margin-right: 4px; + font-weight: 300; + }`); + + // background-color: #d0f6ff; + // background-image: linear-gradient(90deg, #c7fffd 0%, #ffffff 60%); + GM_addStyle(` + tr.completed-platinum { + /* background: rgba(200,255,250,0.6); */ + background-image: linear-gradient(90deg, rgba(200,255,250,0.8) 0%, rgba(200,255,250,0) 60%); + } + `); + GM_addStyle(` + tr.completed-platinum-night { + /* background: rgba(200,255,250,0.1); */ + background-image: linear-gradient(90deg, rgba(200,255,250,0.15) 0%, rgba(200,255,250,0) 60%); + } + `); + + // background-color: #e5ffe7; + // background-image: linear-gradient(90deg, #daffde 0 %, #ffffff 60 %); + GM_addStyle(` + tr.completed-gold { + /* background: rgba(220,255,220,0.6); */ + background-image: linear-gradient(90deg, rgba(220,255,220,0.8) 0%, rgba(220,255,220,0) 60%); + } + `); + GM_addStyle(` + tr.completed-gold-night { + /* background: rgba(101,159,19,0.1); */ + background-image: linear-gradient(90deg, rgba(101,159,19,0.1) 0%, rgba(101,159,19,0) 60%); + } + `); + const tdElements = document.querySelectorAll('table.list tbody > tr'); // 添加完成度染色 - const platinumBackground = 'background-color: #d0f6ff;background-image: linear-gradient(90deg, #c7fffd 0%, #ffffff 60%);'; - const goldBackground = 'background-color: #e5ffe7;background-image: linear-gradient(90deg, #daffde 0%, #ffffff 60%);'; const personalGameCompletions = GM_getValue('personalGameCompletions', []); // 根据已保存的完成度添加染色 @@ -429,8 +469,22 @@ const gameID = tr.getAttribute('id') || 0; const thisGameCompletion = personalGameCompletions.find((item) => item[0] === gameID); if (thisGameCompletion) { - if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === true) { tr.setAttribute('style', platinumBackground); } - if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === false) { tr.setAttribute('style', goldBackground); } + if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === true) { + if (settings.nightMode) { tr.setAttribute('class', 'completed-platinum-night'); } else { tr.setAttribute('class', 'completed-platinum'); } + } + if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === false) { + if (settings.nightMode) { tr.setAttribute('class', 'completed-gold-night'); } else { tr.setAttribute('class', 'completed-gold'); } + } + // 添加进度徽章 + const gameText = tr.querySelector('td.pd10 > p > a'); + if (gameText) { + const completion = thisGameCompletion[1]; + const completionBadge = document.createElement('span'); + completionBadge.className = 'completion-badge'; + completionBadge.textContent = `${completion}%`; + completionBadge.title = '奖杯完成度'; + gameText.parentNode.insertBefore(completionBadge, gameText); + } } }); From b925ac03859dec13d0296e5f008cda8cb72e4c60 Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Fri, 5 Jul 2024 23:34:07 +0800 Subject: [PATCH 06/12] clear --- psnineplus.js | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index 3af01cc..4ed2c14 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -417,7 +417,7 @@ */ const hdElement = document.querySelector('.hd'); if (hdElement && hdElement.textContent.trim() === '游戏列表') { - // 添加自定义的 CSS 类 + // 添加徽章 CSS 类 GM_addStyle(` span.completion-badge { background-color: rgb(5 96 175); @@ -429,8 +429,7 @@ font-weight: 300; }`); - // background-color: #d0f6ff; - // background-image: linear-gradient(90deg, #c7fffd 0%, #ffffff 60%); + // 添加背景 CSS 类含夜间模式 GM_addStyle(` tr.completed-platinum { /* background: rgba(200,255,250,0.6); */ @@ -443,9 +442,6 @@ background-image: linear-gradient(90deg, rgba(200,255,250,0.15) 0%, rgba(200,255,250,0) 60%); } `); - - // background-color: #e5ffe7; - // background-image: linear-gradient(90deg, #daffde 0 %, #ffffff 60 %); GM_addStyle(` tr.completed-gold { /* background: rgba(220,255,220,0.6); */ @@ -455,16 +451,14 @@ GM_addStyle(` tr.completed-gold-night { /* background: rgba(101,159,19,0.1); */ - background-image: linear-gradient(90deg, rgba(101,159,19,0.1) 0%, rgba(101,159,19,0) 60%); + background-image: linear-gradient(90deg, rgba(101,159,19,0.15) 0%, rgba(101,159,19,0) 60%); } `); const tdElements = document.querySelectorAll('table.list tbody > tr'); - // 添加完成度染色 - const personalGameCompletions = GM_getValue('personalGameCompletions', []); - // 根据已保存的完成度添加染色 + const personalGameCompletions = GM_getValue('personalGameCompletions', []); tdElements.forEach((tr) => { const gameID = tr.getAttribute('id') || 0; const thisGameCompletion = personalGameCompletions.find((item) => item[0] === gameID); @@ -488,13 +482,12 @@ } }); - // 创建新的 span 元素 + // 添加按难度排列按钮 const spanElement = document.createElement('span'); spanElement.className = 'btn'; spanElement.textContent = '按难度排列'; - // 添加 span 元素到 .hd 元素中 + // 添加 span 元素并设置样式 hdElement.appendChild(spanElement); - // 添加样式使 span 右对齐 const style = document.createElement('style'); style.textContent = ` .hd { @@ -502,12 +495,7 @@ justify-content: space-between; align-items: center; } - .hd span { - margin-top: 0px; - } - .btn { - cursor: pointer; - } + .hd span { margin-top: 0px; } `; document.head.appendChild(style); From c90470bfce072ad90bca3fa2decd05d386002009 Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Fri, 5 Jul 2024 23:35:41 +0800 Subject: [PATCH 07/12] version up --- psnineplus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psnineplus.js b/psnineplus.js index 4ed2c14..5a25f9b 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -1,7 +1,7 @@ // ==UserScript== // @name PSN中文网功能增强 // @namespace https://swsoyee.github.io -// @version 1.0.23 +// @version 1.0.24 // @description 数折价格走势图,显示人民币价格,奖杯统计和筛选,发帖字数统计和即时预览,楼主高亮,自动翻页,屏蔽黑名单用户发言,被@用户的发言内容显示等多项功能优化P9体验 // eslint-disable-next-line max-len // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAMFBMVEVHcEw0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNs0mNuEOyNSAAAAD3RSTlMAQMAQ4PCApCBQcDBg0JD74B98AAABN0lEQVRIx+2WQRaDIAxECSACWLn/bdsCIkNQ2XXT2bTyHEx+glGIv4STU3KNRccp6dNh4qTM4VDLrGVRxbLGaa3ZQSVQulVJl5JFlh3cLdNyk/xe2IXz4DqYLhZ4mWtHd4/SLY/QQwKmWmGcmUfHb4O1mu8BIPGw4Hg1TEvySQGWoBcItgxndmsbhtJd6baukIKnt525W4anygNECVc1UD8uVbRNbumZNl6UmkagHeRJfX0BdM5NXgA+ZKESpiJ9tRFftZEvue2cS6cKOrGk/IOLTLUcaXuZHrZDq3FB2IonOBCHIy8Bs1Zzo1MxVH+m8fQ+nFeCQM3MWwEsWsy8e8Di7meA5Bb5MDYCt4SnUbP3lv1xOuWuOi3j5kJ5tPiZKahbi54anNRaaG7YElFKQBHR/9PjN3oD6fkt9WKF9rgAAAAASUVORK5CYII= From 3238b4adf1c73d358f8c52d471d2315680621ecb Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Sat, 6 Jul 2024 00:19:01 +0800 Subject: [PATCH 08/12] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AA=E4=BA=BA=E5=AE=8C=E6=88=90=E5=BA=A6?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- psnineplus.js | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index 5a25f9b..aadcb8d 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -429,31 +429,12 @@ font-weight: 300; }`); - // 添加背景 CSS 类含夜间模式 - GM_addStyle(` - tr.completed-platinum { - /* background: rgba(200,255,250,0.6); */ - background-image: linear-gradient(90deg, rgba(200,255,250,0.8) 0%, rgba(200,255,250,0) 60%); - } - `); - GM_addStyle(` - tr.completed-platinum-night { - /* background: rgba(200,255,250,0.1); */ - background-image: linear-gradient(90deg, rgba(200,255,250,0.15) 0%, rgba(200,255,250,0) 60%); - } - `); - GM_addStyle(` - tr.completed-gold { - /* background: rgba(220,255,220,0.6); */ - background-image: linear-gradient(90deg, rgba(220,255,220,0.8) 0%, rgba(220,255,220,0) 60%); - } - `); - GM_addStyle(` - tr.completed-gold-night { - /* background: rgba(101,159,19,0.1); */ - background-image: linear-gradient(90deg, rgba(101,159,19,0.15) 0%, rgba(101,159,19,0) 60%); - } - `); + // 背景 CSS 进度条计算,含夜间模式 + + const progressPlatinumBG = (p) => `background-image: linear-gradient(90deg, rgba(200,240,255,0.6) ${p}%, rgba(200,255,250,0.15) ${p}%)`; + const progressPlatinumBGNight = (p) => `background-image: linear-gradient(90deg, rgba(200,240,255,0.15) ${p}%, rgba(200,255,250,0.05) ${p}%)`; + const progressGoldBG = (p) => `background-image: linear-gradient(90deg, rgba(220,255,220,0.8) ${p}%, rgba(220,255,220,0.15) ${p}%);`; + const progressGoldBGNight = (p) => `background-image: linear-gradient(90deg, rgba(101,159,19,0.15) ${p}%, rgba(101,159,19,0.05) ${p}%);`; const tdElements = document.querySelectorAll('table.list tbody > tr'); @@ -463,11 +444,17 @@ const gameID = tr.getAttribute('id') || 0; const thisGameCompletion = personalGameCompletions.find((item) => item[0] === gameID); if (thisGameCompletion) { - if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === true) { - if (settings.nightMode) { tr.setAttribute('class', 'completed-platinum-night'); } else { tr.setAttribute('class', 'completed-platinum'); } - } - if (thisGameCompletion[1] === 100 && thisGameCompletion[2] === false) { - if (settings.nightMode) { tr.setAttribute('class', 'completed-gold-night'); } else { tr.setAttribute('class', 'completed-gold'); } + // if game hase platinum + if (tr.querySelector('td.pd10 > .meta > em.text-platinum').textContent === '白1') { + if (settings.nightMode) { + tr.setAttribute('style', progressPlatinumBGNight(thisGameCompletion[1])); + } else { + tr.setAttribute('style', progressPlatinumBG(thisGameCompletion[1])); + } + } else if (settings.nightMode) { + tr.setAttribute('style', progressGoldBGNight(thisGameCompletion[1])); + } else { + tr.setAttribute('style', progressGoldBG(thisGameCompletion[1])); } // 添加进度徽章 const gameText = tr.querySelector('td.pd10 > p > a'); From f4e8885ca4aae8d2f07f72d09d8570653e74eb0e Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Sat, 6 Jul 2024 00:32:34 +0800 Subject: [PATCH 09/12] clear --- psnineplus.js | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index aadcb8d..3dbf355 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -430,7 +430,6 @@ }`); // 背景 CSS 进度条计算,含夜间模式 - const progressPlatinumBG = (p) => `background-image: linear-gradient(90deg, rgba(200,240,255,0.6) ${p}%, rgba(200,255,250,0.15) ${p}%)`; const progressPlatinumBGNight = (p) => `background-image: linear-gradient(90deg, rgba(200,240,255,0.15) ${p}%, rgba(200,255,250,0.05) ${p}%)`; const progressGoldBG = (p) => `background-image: linear-gradient(90deg, rgba(220,255,220,0.8) ${p}%, rgba(220,255,220,0.15) ${p}%);`; @@ -440,32 +439,28 @@ // 根据已保存的完成度添加染色 const personalGameCompletions = GM_getValue('personalGameCompletions', []); + tdElements.forEach((tr) => { const gameID = tr.getAttribute('id') || 0; const thisGameCompletion = personalGameCompletions.find((item) => item[0] === gameID); + const gameHasPlatinum = tr.querySelector('td.pd10 > .meta > em.text-platinum').textContent === '白1'; + // if game hase platinum 由于个人页面的白金判断是记录的个人完成度,这里需要判断游戏本身是否有白金 + if (thisGameCompletion) { - // if game hase platinum - if (tr.querySelector('td.pd10 > .meta > em.text-platinum').textContent === '白1') { - if (settings.nightMode) { - tr.setAttribute('style', progressPlatinumBGNight(thisGameCompletion[1])); - } else { - tr.setAttribute('style', progressPlatinumBG(thisGameCompletion[1])); - } - } else if (settings.nightMode) { - tr.setAttribute('style', progressGoldBGNight(thisGameCompletion[1])); - } else { - tr.setAttribute('style', progressGoldBG(thisGameCompletion[1])); - } - // 添加进度徽章 - const gameText = tr.querySelector('td.pd10 > p > a'); - if (gameText) { - const completion = thisGameCompletion[1]; - const completionBadge = document.createElement('span'); - completionBadge.className = 'completion-badge'; - completionBadge.textContent = `${completion}%`; - completionBadge.title = '奖杯完成度'; - gameText.parentNode.insertBefore(completionBadge, gameText); - } + if (gameHasPlatinum && settings.nightMode) { tr.setAttribute('style', progressPlatinumBGNight(thisGameCompletion[1])); } + if (gameHasPlatinum && !settings.nightMode) { tr.setAttribute('style', progressPlatinumBG(thisGameCompletion[1])); } + if (!gameHasPlatinum && settings.nightMode) { tr.setAttribute('style', progressGoldBGNight(thisGameCompletion[1])); } + if (!gameHasPlatinum && !settings.nightMode) { tr.setAttribute('style', progressGoldBG(thisGameCompletion[1])); } + } + // 添加进度徽章 + const gameText = tr.querySelector('td.pd10 > p > a'); + if (gameText) { + const completion = thisGameCompletion[1]; + const completionBadge = document.createElement('span'); + completionBadge.className = 'completion-badge'; + completionBadge.textContent = `${completion}%`; + completionBadge.title = '奖杯完成度'; + gameText.parentNode.insertBefore(completionBadge, gameText); } }); From 17c8791834cefaccc4deb36ed475f612d33cbaae Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Sat, 6 Jul 2024 00:34:22 +0800 Subject: [PATCH 10/12] bug fix --- psnineplus.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/psnineplus.js b/psnineplus.js index 3dbf355..59a646e 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -451,16 +451,16 @@ if (gameHasPlatinum && !settings.nightMode) { tr.setAttribute('style', progressPlatinumBG(thisGameCompletion[1])); } if (!gameHasPlatinum && settings.nightMode) { tr.setAttribute('style', progressGoldBGNight(thisGameCompletion[1])); } if (!gameHasPlatinum && !settings.nightMode) { tr.setAttribute('style', progressGoldBG(thisGameCompletion[1])); } - } - // 添加进度徽章 - const gameText = tr.querySelector('td.pd10 > p > a'); - if (gameText) { - const completion = thisGameCompletion[1]; - const completionBadge = document.createElement('span'); - completionBadge.className = 'completion-badge'; - completionBadge.textContent = `${completion}%`; - completionBadge.title = '奖杯完成度'; - gameText.parentNode.insertBefore(completionBadge, gameText); + // 添加进度徽章 + const gameText = tr.querySelector('td.pd10 > p > a'); + if (gameText) { + const completion = thisGameCompletion[1]; + const completionBadge = document.createElement('span'); + completionBadge.className = 'completion-badge'; + completionBadge.textContent = `${completion}%`; + completionBadge.title = '奖杯完成度'; + gameText.parentNode.insertBefore(completionBadge, gameText); + } } }); From fdeb7989b6a0610af2b55ca4876f36e147cd5bba Mon Sep 17 00:00:00 2001 From: kaikaiiiiiii Date: Sat, 6 Jul 2024 00:38:13 +0800 Subject: [PATCH 11/12] clear --- psnineplus.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/psnineplus.js b/psnineplus.js index 59a646e..c8835bb 100644 --- a/psnineplus.js +++ b/psnineplus.js @@ -435,6 +435,7 @@ const progressGoldBG = (p) => `background-image: linear-gradient(90deg, rgba(220,255,220,0.8) ${p}%, rgba(220,255,220,0.15) ${p}%);`; const progressGoldBGNight = (p) => `background-image: linear-gradient(90deg, rgba(101,159,19,0.15) ${p}%, rgba(101,159,19,0.05) ${p}%);`; + // 获取游戏列表下所有游戏的 DOM 元素指针 const tdElements = document.querySelectorAll('table.list tbody > tr'); // 根据已保存的完成度添加染色 @@ -443,8 +444,8 @@ tdElements.forEach((tr) => { const gameID = tr.getAttribute('id') || 0; const thisGameCompletion = personalGameCompletions.find((item) => item[0] === gameID); - const gameHasPlatinum = tr.querySelector('td.pd10 > .meta > em.text-platinum').textContent === '白1'; // if game hase platinum 由于个人页面的白金判断是记录的个人完成度,这里需要判断游戏本身是否有白金 + const gameHasPlatinum = tr.querySelector('td.pd10 > .meta > em.text-platinum').textContent === '白1'; if (thisGameCompletion) { if (gameHasPlatinum && settings.nightMode) { tr.setAttribute('style', progressPlatinumBGNight(thisGameCompletion[1])); } From 790eb9d43146784c6727694e64612acaf83e9c43 Mon Sep 17 00:00:00 2001 From: InfinityLoop Date: Sat, 6 Jul 2024 11:58:19 +0900 Subject: [PATCH 12/12] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ba26c17..7b9ccaa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "psnine-enhanced-version", - "version": "1.0.23", + "version": "1.0.24", "description": "数折价格走势图,显示人民币价格,奖杯统计和筛选,发帖字数统计和即时预览,楼主高亮,自动翻页,屏蔽黑名单用户发言,被@用户的发言内容显示等多项功能优化P9体验", "main": "night-mode-css.js", "scripts": {