//在popup.js 中调用 backgourd.js 中的变量和方法,很重要 var bg = chrome.extension.getBackgroundPage(); const serverUrl = 'https://going.run/assist' // 登录按钮点击 document.getElementsByClassName('login-button')[0].onclick = function () { const username = document.getElementById('username').value const password = document.getElementById('password').value if (!username || !password) { chrome.notifications.create(null, { type: 'basic', iconUrl: 'img/48.png', title: '运行方案', message: '用户名或密码不能为空!' }) return } fetch(`http://going.run/userServer?route=login`, { method: 'POST', headers: { "Content-Type": "application/json" }, body: JSON.stringify({ type: "assist", username: username, password: password }) }).then((response) => {return response.json();}).then((res) => { if (res.err === 0) { bg.userInfo = res.data bg.saveUser(username, password) location.reload(); } }) } if (bg.userInfo) { document.querySelector('.login-box').style.display = 'none' let newHtml = `
| 编号 | 脚本名称 | 开启状态 |
|---|---|---|
| ${element.id} | ${element.name} |