Created
June 9, 2024 16:05
-
-
Save gledos/22ce3b5da2a6684423891959dc5c02f8 to your computer and use it in GitHub Desktop.
Chrome 域前置启动项生成器
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
<!DOCTYPE html> | |
<html lang="zh"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Chrome 域前置启动项生成器</title> | |
</head> | |
<body> | |
<h1>Chrome 域前置启动项生成器</h1> | |
<p>复刻自:<a href="https://github.com/SpaceTimee/Sheas-Cealer">https://github.com/SpaceTimee/Sheas-Cealer</a></p> | |
<textarea id="inputArea" rows="10" cols="50"> | |
[ | |
[["example.com"],"example.org","192.0.2.0"] | |
] | |
</textarea | |
> | |
<br /><br /> | |
<button onclick="generateCommand()">生成</button> | |
<h2>Generated Command:</h2> | |
<p id="outputArea"></p> | |
<script> | |
function generateCommand() { | |
const input = document.getElementById("inputArea").value; | |
const data = JSON.parse(input); | |
let hostRules = []; | |
let resolverRules = []; | |
let randomMap = new Map(); | |
data.forEach((entry) => { | |
const domains = entry[0]; | |
const targetDomain = entry[1]; | |
const ipAddress = entry[2]; | |
if (targetDomain) { | |
domains.forEach((domain) => { | |
hostRules.push(`MAP ${domain} ${targetDomain}`); | |
}); | |
resolverRules.push(`MAP ${targetDomain} ${ipAddress}`); | |
} else { | |
const randomKey = Math.random().toString(36).substring(7); | |
randomMap.set(randomKey, ipAddress); | |
domains.forEach((domain) => { | |
hostRules.push(`MAP ${domain} ${randomKey}`); | |
}); | |
resolverRules.push(`MAP ${randomKey} ${ipAddress}`); | |
} | |
}); | |
const hostRulesStr = hostRules.join(", "); | |
const resolverRulesStr = resolverRules.join(", "); | |
const command = `chrome.exe --host-rules="${hostRulesStr}" --host-resolver-rules="${resolverRulesStr}" --test-type --ignore-certificate-errors`; | |
document.getElementById("outputArea").innerText = command; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment