Skip to content

Commit

Permalink
📖 更新文章
Browse files Browse the repository at this point in the history
  • Loading branch information
fxzer committed Jan 5, 2024
1 parent d458cc3 commit c84b53f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions docs/.vitepress/sidebar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ export default {
{
"text": "自动部署脚本",
"link": "/FrontEnd/Shell/自动部署脚本"
},
{
"text": "获取页面所有域名并去重",
"link": "/FrontEnd/Shell/获取页面所有域名并去重"
}
]
},
Expand Down
49 changes: 49 additions & 0 deletions docs/FrontEnd/Shell/获取页面所有域名并去重.md
Original file line number Diff line number Diff line change
@@ -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)
})()
```
2 changes: 1 addition & 1 deletion scripts/generate-sidebar.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down

0 comments on commit c84b53f

Please sign in to comment.