// ==UserScript== // @name 在控制台输出TL-WDR5620(千兆版)的MAC绑定内容 // @namespace http://tampermonkey.net/ // @version 1.0.4 // @description // @author simon // @match http://192.168.3.1 // @match http://192.168.0.1 // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @license MIT // @description TP路由器TL-WDR5620(兼容千兆版)的MAC绑定内容 // @downloadURL none // ==/UserScript== window.onload = function () { 'use strict'; // 注册菜单 GM_registerMenuCommand('#️⃣ 操作', function () { const modalHtml = ` `; // 获取模态框和输入框元素 let modal = document.getElementById('myModal'); if (modal == null) { // 将模态框添加到页面 document.body.insertAdjacentHTML('beforeend', modalHtml); //重新获取模态框 modal = document.getElementById('myModal'); jQuery("#btnGetMACList").click(function () { var t = ""; jQuery('#ipMacBindLease tbody tr').each(function () { // 创建一个空字符串来存储每行的内容 var rowContent = ''; let tdid = 0; // 遍历每个单元格 jQuery(this).find('td').each(function () { // 获取单元格的文本内容,并追加到行内容字符串中 if (tdid == 1) { var title = jQuery(this).attr('title'); if (title) { rowContent += title + '\t'; } else { rowContent += jQuery(this).text() + '\t'; } }else if(tdid == 2){ rowContent += jQuery(this).text().replace(/[-]/g,":") + '\t'; }else { rowContent += jQuery(this).text() + '\t'; // 可根据需要使用适当的分隔符 } tdid++; }); // 添加换行符 rowContent += '\n'; // 打印或使用行内容 console.log(rowContent); t += rowContent; // 在这里你可以将 rowContent 用于其他目的,比如拼接到字符串、显示在页面上等 }); jQuery("#resultlist").val(t); }); } // 打开模态框 jQuery(modal).modal('show'); }); // 动态添加 Bootstrap CSS 样式文件 const bootstrapCss = document.createElement('link'); bootstrapCss.rel = 'stylesheet'; bootstrapCss.href = 'https://cdn.staticfile.org/bootstrap/5.3.1/css/bootstrap.min.css'; // 根据实际路径进行修改 document.head.appendChild(bootstrapCss); // 动态添加 jQuery 和 Bootstrap JavaScript 文件 const jQueryScript = document.createElement('script'); jQueryScript.src = 'https://cdn.staticfile.org/jquery/3.7.0/jquery.min.js'; console.log("输出$"); console.log($); jQueryScript.onload = function () { const bootstrapJs = document.createElement('script'); bootstrapJs.src = 'https://cdn.staticfile.org/bootstrap/5.3.1/js/bootstrap.min.js'; document.head.appendChild(bootstrapJs); var j1 = jQuery.noConflict(); }; document.head.appendChild(jQueryScript); };