介绍
chrome 获取mac地址插件
软件架构
参考chrome插件开发规范
安装教程
将插件根目录拷贝到任意磁盘目录,一旦选定切勿搬移,目录名不包含空格。
修改manifest.json 中matches属性为要启用的网站域名
安装chrome浏览器,打开浏览器 => 更多工具 => 扩展程序 => 开发者模式 => 加载已解压的扩展程序 => 选中插件根目录完成。
查看插件id,确保com.yd.macaddr.nativemessage.json 文件中chrome-extension 的id保持一致。关闭开发者模式。
点击运行host-install.bat 显示安装成功。(运行host-uninstall.bat 进行下载)
使用说明
以上步骤完成后,在项目代码中即可从浏览器localstorage中获取mac地址。 例:var mac = localStorage.getItem("mac")
https://gitee.com/xcj0654335/macaddr-chrome-extension
https://blog.csdn.net/zhangjs712/article/details/50913114?utm_medium=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-3.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-3.nonecas
https://blog.csdn.net/weixin_33840661/article/details/87948213?utm_medium=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-2.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-2.nonecas
chrome 扩展制作步骤
https://www.cnblogs.com/liuxianan/p/chrome-plugin-develop.html
ie获取mac地址
<HTML>
<HEAD>
<TITLE>WMI Scripting HTML</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=foo>
document.forms[0].txtMACAddr.value=unescape(MACAddr);
document.forms[0].txtIPAddr.value=unescape(IPAddr);
document.forms[0].txtDNSName.value=unescape(sDNSName);
//document.formbar.submit();
</SCRIPT>
<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined")
IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;
}
</SCRIPT>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT></OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223></OBJECT>
<SCRIPT language=JScript>
var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</SCRIPT>
<FORM id="formfoo" name="formbar" action="index.do" method="post">
<INPUT value="00-11-11-B4-52-EF" name="txtMACAddr">
<INPUT value="210.42.38.50" name="txtIPAddr">
<INPUT value="zhupan" name="txtDNSName">
</FORM>
</BODY>
</HTML>
2文章来源:https://www.toymoban.com/news/detail-460945.html
function getMac() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator"); // 创建ActiveXObject对象
var service = locator.ConnectServer("."); //连接本机服务器
var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = TRUE"); // 查询地址适配器信息
var e = new Enumerator(properties);
var macs = [];
for (; !e.atEnd(); e.moveNext()) {
macs.push(e.item().MACAddress);
}
alert(macs.join(","));
// return macs.join(","); // 用逗号拼接mac数组
}
3文章来源地址https://www.toymoban.com/news/detail-460945.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS获取客户端MAC地址</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<style type="text/css">
</style>
<script event="OnObjectReady(objObject,objAsyncContext)" for="foo">
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true) {
if(objObject.MACAddress != null && objObject.MACAddress != "undefined" && objObject.DNSServerSearchOrder!=null)
MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined" && objObject.DNSServerSearchOrder!=null)
IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;
}
</script>
<script type="text/javascript">
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
function init() {
var service = locator.ConnectServer();
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
}
function getMac() {
document.getElementById('txtMac').value = unescape(MACAddr);
}
function getIp()
{
document.getElementById('txtIp').value = unescape(IPAddr);
}
</script>
</head>
<body onload="init()">
<object id="locator" classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" VIEWASTEXT></object>
<object id="foo" classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223"></object>
<input type="text" id="txtMac" />
<input type="button" id="btn" value="获取Mac地址" onclick="getMac();" />
<input type="text" id="txtIp" />
<input type="button" id="btn" value="获取ip地址" onclick="getIp();" />
</body>
</html>```
到了这里,关于google Chrome通过 扩展程序获取windows MAC地址的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!