适配v3
parent
0ed2c11370
commit
1fcc0ec2f8
|
@ -4,20 +4,17 @@
|
|||
* @date 2020/11/04 17:54:49
|
||||
*/
|
||||
|
||||
chrome.browserAction.onClicked.addListener(function(ctab) {
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
chrome.action.onClicked.addListener(function (ctab) {
|
||||
var cid = ctab.id
|
||||
var tid = null
|
||||
var code = `
|
||||
var script = document.createElement('script')
|
||||
script.textContent = \`
|
||||
chrome.send('clearHostResolverCache')
|
||||
chrome.send('flushSocketPools')
|
||||
\`
|
||||
document.body.appendChild(script)
|
||||
`
|
||||
|
||||
var callback = function () {
|
||||
chrome.tabs.remove(tid)
|
||||
chrome.tabs.executeScript(cid, { code: 'location.reload()' })
|
||||
chrome.scripting.executeScript({
|
||||
target: { tabId: cid },
|
||||
files: ['done.js']
|
||||
})
|
||||
}
|
||||
|
||||
chrome.tabs.query({}, function (tabs) {
|
||||
|
@ -25,7 +22,10 @@ chrome.browserAction.onClicked.addListener(function(ctab) {
|
|||
for (let i = 0, tab; (tab = tabs[i++]); ) {
|
||||
if (/^chrome:\/\/net-internals/.test(tab.url)) {
|
||||
tid = tab.id
|
||||
chrome.tabs.executeScript(tab.id, { code }, callback)
|
||||
chrome.scripting.executeScript(
|
||||
{ target: { tabId: tab.id }, files: ['clean.js'] },
|
||||
callback
|
||||
)
|
||||
done = true
|
||||
break
|
||||
}
|
||||
|
@ -35,9 +35,13 @@ chrome.browserAction.onClicked.addListener(function(ctab) {
|
|||
{ url: 'chrome://net-internals/#dns', active: false },
|
||||
function (tab) {
|
||||
tid = tab.id
|
||||
chrome.tabs.executeScript(tab.id, { code }, callback)
|
||||
chrome.scripting.executeScript(
|
||||
{ target: { tabId: tab.id }, files: ['clean.js'] },
|
||||
callback
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
console.log(chrome)
|
||||
// chrome.send('clearHostResolverCache')
|
||||
// chrome.send('flushSocketPools')
|
||||
|
||||
window['dns-view-clear-cache'].click()
|
||||
window['sockets-view-flush-button'].click()
|
BIN
icon128.png
BIN
icon128.png
Binary file not shown.
Before Width: | Height: | Size: 5.2 KiB |
BIN
icon256.png
BIN
icon256.png
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
BIN
icon64.png
BIN
icon64.png
Binary file not shown.
Before Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -1,24 +1,24 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"manifest_version": 3,
|
||||
"name": "dns-killer",
|
||||
"description": "DNS缓存杀手,一键清除chrome的DNS缓存, 并刷新当前选项卡。 web开发的利器。",
|
||||
"version": "1.0.0",
|
||||
"version": "2.0.0",
|
||||
"author": "yutent",
|
||||
"icons": {
|
||||
"64": "icon64.png",
|
||||
"128": "icon128.png",
|
||||
"256": "icon256.png"
|
||||
"64": "icons/64.png",
|
||||
"128": "icons/128.png",
|
||||
"256": "icons/256.png"
|
||||
},
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
"service_worker": "background.js",
|
||||
"type": "module"
|
||||
},
|
||||
"browser_action": {
|
||||
"default_icon": "icon64.png"
|
||||
"action": {
|
||||
"default_icon": { "64": "icons/64.png", "128": "icons/128.png" },
|
||||
"default_title": "点击清除DNS缓存"
|
||||
},
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"chrome://net-internals/#dns",
|
||||
"chrome://extensions/"
|
||||
],
|
||||
"homepage_url": "https://yutent.top"
|
||||
"permissions": ["tabs", "activeTab", "scripting"],
|
||||
"host_permissions": ["chrome://net-internals/#dns"],
|
||||
"optional_host_permissions": ["chrome://extensions/"],
|
||||
"homepage_url": "https://github.com/yutent"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue