-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
})() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters