-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
有没有什么办法通过扩充组件获取设备mac地址? #30
Comments
如果你是 windows 系統的話,可以用如下的方式執行外部指令以獲取 MAC 地址: var exec = require('child_process').exec;
var regexRegex = /[-\/\\^$*+?.()|[\]{}]/g;
function escape(string) {
return string.replace(regexRegex, '\\$&');
}
function getMAC(iface) {
exec("ipconfig /all", function (err, out) {
if (err) {
console.warn(err);
return;
}
var match = new RegExp(escape(iface)).exec(out);
if (!match) {
console.warn("did not find interface in `ipconfig /all`");
return;
}
out = out.substring(match.index + iface.length);
match = /[A-Fa-f0-9]{2}(\-[A-Fa-f0-9]{2}){5}/.exec(out);
if (!match) {
console.warn("did not find a mac address");
return;
}
return match[0].toLowerCase().replace(/\-/g, ':');
});
} |
這部分錯誤的原因是因為安全性的問題,在 Content Scripts 中不允許 順帶一提,我發現您好像沒有 Chrome Extensions 相關開發基礎,這邊給您相關教學網站,您有些問題都可以從裡面參考(包括像是我前面提到的 最後,因為本專案還在持續開發中,部分 chrome API 也還沒有實作完全,如果您在使用中發現某些 API 有問題,建議您先看一下這個討論串,這是目前 chrome API 的支援程度。 |
好的,十分感谢! |
No description provided.
The text was updated successfully, but these errors were encountered: