From b37e29c187ed3f4786fe712f56721fbf52c890dd Mon Sep 17 00:00:00 2001 From: Tw93 Date: Mon, 9 Dec 2024 20:32:09 +0800 Subject: [PATCH] :bug: xiaohongshu style and jump fixed --- apps.conf.json | 76 ----------------------------------- default_app_list.json | 74 ++++++++++++++++++++++++++++++++++ src-tauri/src/inject/event.js | 31 +++++--------- src-tauri/src/inject/style.js | 7 +++- 4 files changed, 91 insertions(+), 97 deletions(-) delete mode 100644 apps.conf.json create mode 100644 default_app_list.json diff --git a/apps.conf.json b/apps.conf.json deleted file mode 100644 index 1a86fbe..0000000 --- a/apps.conf.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "apps": [ - { - "name": "programmusic", - "title": "ProgramMusic", - "name_zh": "ProgramMusic", - "url": "https://musicforprogramming.net/" - }, - { - "name": "twitter", - "title": "Twitter", - "name_zh": "推特", - "url": "https://twitter.com/" - }, - { - "name": "youtube", - "title": "YouTube", - "name_zh": "YouTube", - "url": "https://www.youtube.com" - }, - { - "name": "coderunner", - "title": "CodeRunner", - "name_zh": "CodeRunner", - "url": "https://riju.codes/" - }, - { - "name": "chatgpt", - "title": "ChatGPT", - "name_zh": "ChatGPT", - "url": "https://chatgpt.com/" - }, - { - "name": "flomo", - "title": "Flomo", - "name_zh": "浮墨", - "url": "https://v.flomoapp.com/mine" - }, - { - "name": "qwerty", - "title": "Qwerty", - "name_zh": "Qwerty", - "url": "https://qwerty.kaiyi.cool/" - }, - { - "name": "lizhi", - "title": "LiZhi", - "name_zh": "李志", - "url": "https://lizhi.turkyden.com/?from=pake" - }, - { - "name": "xiaohongshu", - "title": "XiaoHongShu", - "name_zh": "小红书", - "url": "https://www.xiaohongshu.com/explore" - }, - { - "name": "poe", - "title": "Poe", - "name_zh": "Poe", - "url": "https://poe.com/" - }, - { - "name": "youtubemusic", - "title": "YouTubeMusic", - "name_zh": "YouTubeMusic", - "url": "https://music.youtube.com/" - }, - { - "name": "weread", - "title": "WeRead", - "name_zh": "微信阅读", - "url": "https://weread.qq.com/" - } - ] -} diff --git a/default_app_list.json b/default_app_list.json new file mode 100644 index 0000000..fdb1090 --- /dev/null +++ b/default_app_list.json @@ -0,0 +1,74 @@ +[ + { + "name": "programmusic", + "title": "ProgramMusic", + "name_zh": "ProgramMusic", + "url": "https://musicforprogramming.net/" + }, + { + "name": "twitter", + "title": "Twitter", + "name_zh": "推特", + "url": "https://twitter.com/" + }, + { + "name": "youtube", + "title": "YouTube", + "name_zh": "YouTube", + "url": "https://www.youtube.com" + }, + { + "name": "coderunner", + "title": "CodeRunner", + "name_zh": "CodeRunner", + "url": "https://riju.codes/" + }, + { + "name": "chatgpt", + "title": "ChatGPT", + "name_zh": "ChatGPT", + "url": "https://chatgpt.com/" + }, + { + "name": "flomo", + "title": "Flomo", + "name_zh": "浮墨", + "url": "https://v.flomoapp.com/mine" + }, + { + "name": "qwerty", + "title": "Qwerty", + "name_zh": "Qwerty", + "url": "https://qwerty.kaiyi.cool/" + }, + { + "name": "lizhi", + "title": "LiZhi", + "name_zh": "李志", + "url": "https://lizhi.turkyden.com/?from=pake" + }, + { + "name": "xiaohongshu", + "title": "XiaoHongShu", + "name_zh": "小红书", + "url": "https://www.xiaohongshu.com/explore" + }, + { + "name": "poe", + "title": "Poe", + "name_zh": "Poe", + "url": "https://poe.com/" + }, + { + "name": "youtubemusic", + "title": "YouTubeMusic", + "name_zh": "YouTubeMusic", + "url": "https://music.youtube.com/" + }, + { + "name": "weread", + "title": "WeRead", + "name_zh": "微信阅读", + "url": "https://weread.qq.com/" + } +] diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.js index 77a5d72..e3f79a4 100644 --- a/src-tauri/src/inject/event.js +++ b/src-tauri/src/inject/event.js @@ -51,11 +51,6 @@ function isDownloadLink(url) { return downloadLinkPattern.test(url); } -// No need to go to the download link. -function externalDownLoadLink() { - return ['quickref.me'].indexOf(location.hostname) > -1; -} - document.addEventListener('DOMContentLoaded', () => { const tauri = window.__TAURI__; const appWindow = tauri.window.getCurrentWindow(); @@ -192,35 +187,31 @@ document.addEventListener('DOMContentLoaded', () => { }); }; - const handleDownloadLink = (e, url, filename) => { - e.preventDefault(); - invoke('download_file', { params: { url, filename } }); - }; - const detectAnchorElementClick = e => { const anchorElement = e.target.closest('a'); if (anchorElement && anchorElement.href) { - + const target = anchorElement.target; const hrefUrl = new URL(anchorElement.href); const absoluteUrl = hrefUrl.href; let filename = anchorElement.download || getFilenameFromUrl(absoluteUrl); // Handling external link redirection, _blank will automatically open. - if (isExternalLink(absoluteUrl) && (['_new'].includes(anchorElement.target))) { + if (target === '_blank') { + e.preventDefault(); + return; + } + + if (target === '_new') { + e.preventDefault(); handleExternalLink(absoluteUrl); return; } // Process download links for Rust to handle. - if (isDownloadRequired(absoluteUrl, anchorElement, e) && !externalDownLoadLink() && !isSpecialDownload(absoluteUrl)) { - handleDownloadLink(e, absoluteUrl, filename); - return; - } - - // App internal jump. - if (!anchorElement.target) { - location.href = anchorElement.href; + if (isDownloadRequired(absoluteUrl, anchorElement, e) && !isSpecialDownload(absoluteUrl)) { + e.preventDefault(); + invoke('download_file', { params: { url: absoluteUrl, filename } }); } } }; diff --git a/src-tauri/src/inject/style.js b/src-tauri/src/inject/style.js index 405fd93..66d707b 100644 --- a/src-tauri/src/inject/style.js +++ b/src-tauri/src/inject/style.js @@ -119,7 +119,8 @@ window.addEventListener('DOMContentLoaded', _event => { display: none !important; } - #react-root [data-testid="DMDrawer"] { + #react-root [data-testid="DMDrawer"], + #root > main > footer.justify-center.ease-in { visibility: hidden !important; } @@ -386,6 +387,10 @@ window.addEventListener('DOMContentLoaded', _event => { .lark > .main-wrapper [data-testid="aside"] { top: 15px; } + + #global > div.header-container > .mask-paper { + padding-top: 20px; + } #background.ytd-masthead { height: 68px;