master
宇天 2020-11-04 17:59:31 +08:00
parent 924dd5bd0b
commit 09a2776dfa
6 changed files with 21 additions and 24 deletions

View File

@ -1,9 +1,12 @@
## DNS 缓存清除 ## DNS缓存杀手
> 一键清除chrome的DNS缓存, 并刷新当前选项卡。 web开发的利器。 > DNS缓存杀手,一键清除chrome的DNS缓存, 并刷新当前选项卡。 web开发的利器。
### 更新日志 ### 更新日志
#### 2020/11/04 - v1.0.0
* 发布到chrome store。
#### 2018/07/29 - v0.3.0 #### 2018/07/29 - v0.3.0
* 兼容chrome 68+ * 兼容chrome 68+
* chrome 68+之后, 谷歌移除了原清除DNS的API方法, 所以只能通过打开`chrome://net-internals/#dns`页面, 进行js注入的方式来清除缓存。 * chrome 68+之后, 谷歌移除了原清除DNS的API方法, 所以只能通过打开`chrome://net-internals/#dns`页面, 进行js注入的方式来清除缓存。

View File

@ -1,28 +1,27 @@
/** /**
* * DNS缓存杀手
* @authors yutent (yutent@doui.cc) * @author yutent<yutent.io@gmail.com>
* @date 2018-07-07 20:59:35 * @date 2020/11/04 17:54:49
* @version $Id$
*/ */
chrome.browserAction.onClicked.addListener(function(ctab) { chrome.browserAction.onClicked.addListener(function(ctab) {
let cid = ctab.id var cid = ctab.id
let tid = null var tid = null
let code = ` var code = `
let script = document.createElement('script') var script = document.createElement('script')
script.textContent = \` script.textContent = \`
chrome.send('clearHostResolverCache') chrome.send('clearHostResolverCache')
chrome.send('flushSocketPools') chrome.send('flushSocketPools')
\` \`
document.body.appendChild(script) document.body.appendChild(script)
` `
let callback = function() { var callback = function() {
chrome.tabs.remove(tid) chrome.tabs.remove(tid)
chrome.tabs.executeScript(cid, { code: 'location.reload()' }) chrome.tabs.executeScript(cid, { code: 'location.reload()' })
} }
chrome.tabs.query({}, function(tabs) { chrome.tabs.query({}, function(tabs) {
let done = false var done = false
for (let i = 0, tab; (tab = tabs[i++]); ) { for (let i = 0, tab; (tab = tabs[i++]); ) {
if (/^chrome:\/\/net-internals/.test(tab.url)) { if (/^chrome:\/\/net-internals/.test(tab.url)) {
tid = tab.id tid = tab.id

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,9 +1,8 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "dns-killer",
"name": "DNS Flush", "description": "DNS缓存杀手,一键清除chrome的DNS缓存, 并刷新当前选项卡。 web开发的利器。",
"description": "一键清除chrome的DNS缓存, 并刷新当前选项卡。 web开发的利器。", "version": "1.0.0",
"version": "0.3",
"author": "yutent", "author": "yutent",
"icons": { "icons": {
"64": "icon64.png", "64": "icon64.png",
@ -11,15 +10,11 @@
"256": "icon256.png" "256": "icon256.png"
}, },
"background": { "background": {
"scripts": [ "background.js" ] "scripts": ["background.js"]
}, },
"browser_action": { "browser_action": {
"default_icon": "icon64.png" "default_icon": "icon64.png"
}, },
"permissions": [ "permissions": ["tabs", "chrome://net-internals/#dns", "*://*/*"],
"tabs", "homepage_url": "https://yutent.me"
"chrome://net-internals/#dns",
"*://*/*"
],
"homepage_url": "https://doui.cc"
} }