google Chrome通过 扩展程序获取windows MAC地址

这篇具有很好参考价值的文章主要介绍了google Chrome通过 扩展程序获取windows MAC地址。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

介绍

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

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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包