From c84b53f3f45ed531146f3d2e2319c35d2dacdf4c Mon Sep 17 00:00:00 2001 From: fxzer Date: Fri, 5 Jan 2024 14:30:19 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20=E6=9B=B4=E6=96=B0=E6=96=87?= =?UTF-8?q?=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- docs/.vitepress/sidebar/index.ts | 4 ++ ...15\345\271\266\345\216\273\351\207\215.md" | 49 +++++++++++++++++++ scripts/generate-sidebar.cjs | 2 +- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 "docs/FrontEnd/Shell/\350\216\267\345\217\226\351\241\265\351\235\242\346\211\200\346\234\211\345\237\237\345\220\215\345\271\266\345\216\273\351\207\215.md" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 50555db2..30451033 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,7 +33,7 @@ jobs: uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.DEPLOY_TOKEN }} - publish_dir: ./dist + publish_dir: ./dist # 部署的目录 user_name: github-actions[bot] user_email: github-actions[bot]@users.noreply.github.com diff --git a/docs/.vitepress/sidebar/index.ts b/docs/.vitepress/sidebar/index.ts index 2b747800..fafd6186 100644 --- a/docs/.vitepress/sidebar/index.ts +++ b/docs/.vitepress/sidebar/index.ts @@ -238,6 +238,10 @@ export default { { "text": "自动部署脚本", "link": "/FrontEnd/Shell/自动部署脚本" + }, + { + "text": "获取页面所有域名并去重", + "link": "/FrontEnd/Shell/获取页面所有域名并去重" } ] }, diff --git "a/docs/FrontEnd/Shell/\350\216\267\345\217\226\351\241\265\351\235\242\346\211\200\346\234\211\345\237\237\345\220\215\345\271\266\345\216\273\351\207\215.md" "b/docs/FrontEnd/Shell/\350\216\267\345\217\226\351\241\265\351\235\242\346\211\200\346\234\211\345\237\237\345\220\215\345\271\266\345\216\273\351\207\215.md" new file mode 100644 index 00000000..ca264f54 --- /dev/null +++ "b/docs/FrontEnd/Shell/\350\216\267\345\217\226\351\241\265\351\235\242\346\211\200\346\234\211\345\237\237\345\220\215\345\271\266\345\216\273\351\207\215.md" @@ -0,0 +1,49 @@ +## 获取当前页所有域名并写入剪切板 + +```js +javascript:(async function () { + const domains = new Set() + window.performance.getEntriesByType('resource').forEach((resource) => { + const url = new URL(resource.name) + domains.add(url.hostname) + }) + const domainList = Array.from(domains) + function copy(value) { + const ta = document.createElement('textarea') + ta.value = value ?? '' + ta.style.position = 'absolute' + ta.style.opacity = '0' + document.body.appendChild(ta) + ta.select() + document.execCommand('copy') + ta.remove() + }; + console.log('%c数组:\n', 'color: green; font-weight: bold;', domainList) + console.log('%c字符串:\n', 'color: green; font-weight: bold;', domainList.join('\n')) + copy(JSON.stringify(domainList)) +})() +``` + +## 把此网站的多个页面所引用的页面去重 + +```js +javascript:(async function () { + const input = prompt('请输入字符串数组,用英文逗号分隔') + const matches = input.match(/"(.*?)"/g).map((val) => { + return val.slice(1, -1) + }) + function copy(value) { + const ta = document.createElement('textarea') + ta.value = value ?? '' + ta.style.position = 'absolute' + ta.style.opacity = '0' + document.body.appendChild(ta) + ta.select() + document.execCommand('copy') + ta.remove() + }; + const output = Array.from(new Set(matches)).join('\n') + console.log('%c字符串:\n', 'color: green; font-weight: bold;', output) + copy(output) +})() +``` diff --git a/scripts/generate-sidebar.cjs b/scripts/generate-sidebar.cjs index 797700ab..6e9de8d2 100644 --- a/scripts/generate-sidebar.cjs +++ b/scripts/generate-sidebar.cjs @@ -103,7 +103,7 @@ function writeToFile(sidebarObj) { fs.mkdirSync(path.dirname(sidebarPath), { recursive: true }) fs.writeFile(sidebarPath, `export default ${sidebarStr}`, (err) => { - console.log('[ err ]-106', err) + console.log('写入失败:', err && err.message) }) }