|
@@ -1,7 +1,7 @@
|
|
|
//在popup.js 中调用 backgourd.js 中的变量和方法,很重要
|
|
//在popup.js 中调用 backgourd.js 中的变量和方法,很重要
|
|
|
var bg = chrome.extension.getBackgroundPage();
|
|
var bg = chrome.extension.getBackgroundPage();
|
|
|
// bg.count = bg.count+1;
|
|
// bg.count = bg.count+1;
|
|
|
-console.log(bg)
|
|
|
|
|
|
|
+// console.log(bg)
|
|
|
const serverUrl = 'https://going.run/assist'
|
|
const serverUrl = 'https://going.run/assist'
|
|
|
|
|
|
|
|
function owoReplaceAll(str, s1, s2) {
|
|
function owoReplaceAll(str, s1, s2) {
|
|
@@ -13,18 +13,20 @@ function owoReplaceAll(str, s1, s2) {
|
|
|
|
|
|
|
|
const getSchemeData = new Promise((resolve, reject) => {
|
|
const getSchemeData = new Promise((resolve, reject) => {
|
|
|
getCurrentTabId((tabInfo) => {
|
|
getCurrentTabId((tabInfo) => {
|
|
|
- // alert(userInfo.username)
|
|
|
|
|
- fetch(`${serverUrl}?route=search&username=${userInfo.username || 'nologin'}`, {
|
|
|
|
|
- method: 'POST',
|
|
|
|
|
- body: JSON.stringify({
|
|
|
|
|
- "edition": 5,
|
|
|
|
|
- "url": tabInfo.url
|
|
|
|
|
- }),
|
|
|
|
|
- redirect: 'follow'
|
|
|
|
|
- }).then(data => data.json()).then(dataTemp => {
|
|
|
|
|
- dataTemp.tabInfo = tabInfo
|
|
|
|
|
- resolve(dataTemp)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ fetch(`${serverUrl}?route=search&username=${userInfo.username || 'nologin'}`, {
|
|
|
|
|
+ method: 'POST',
|
|
|
|
|
+ body: JSON.stringify({
|
|
|
|
|
+ "edition": 5,
|
|
|
|
|
+ "url": tabInfo.url
|
|
|
|
|
+ }),
|
|
|
|
|
+ redirect: 'follow'
|
|
|
|
|
+ }).then(data => data.json()).then(dataTemp => {
|
|
|
|
|
+ dataTemp.tabInfo = tabInfo
|
|
|
|
|
+ resolve(dataTemp)
|
|
|
|
|
+ })
|
|
|
|
|
+ }, 100);
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -57,7 +59,7 @@ let dataCopy = null
|
|
|
|
|
|
|
|
function load() {
|
|
function load() {
|
|
|
chrome.storage.sync.get('userInfo', function(data) {
|
|
chrome.storage.sync.get('userInfo', function(data) {
|
|
|
- console.log(data)
|
|
|
|
|
|
|
+ // alert(data)
|
|
|
userInfo = data.userInfo
|
|
userInfo = data.userInfo
|
|
|
if (userInfo && userInfo.username && userInfo.password && userInfo.session) {
|
|
if (userInfo && userInfo.username && userInfo.password && userInfo.session) {
|
|
|
document.querySelector('.userInfo').innerHTML = `${userInfo.username}`
|
|
document.querySelector('.userInfo').innerHTML = `${userInfo.username}`
|
|
@@ -65,7 +67,7 @@ function load() {
|
|
|
// alert("页面加载完成!");
|
|
// alert("页面加载完成!");
|
|
|
// 获取是否有脚本
|
|
// 获取是否有脚本
|
|
|
getSchemeData.then((dataTemp) => {
|
|
getSchemeData.then((dataTemp) => {
|
|
|
- console.log(dataTemp)
|
|
|
|
|
|
|
+ // console.log(dataTemp)
|
|
|
const scriptBox = document.getElementsByClassName('script-box')[0]
|
|
const scriptBox = document.getElementsByClassName('script-box')[0]
|
|
|
if (dataTemp.edition > 5) {
|
|
if (dataTemp.edition > 5) {
|
|
|
chrome.notifications.create(null, {
|
|
chrome.notifications.create(null, {
|
|
@@ -137,7 +139,6 @@ function load() {
|
|
|
script.type = "text/javascript";
|
|
script.type = "text/javascript";
|
|
|
script.charset = "UTF-8";
|
|
script.charset = "UTF-8";
|
|
|
script.innerHTML = clearOwo(\`${decodeOwo(dataTempCopy.data)}\`);
|
|
script.innerHTML = clearOwo(\`${decodeOwo(dataTempCopy.data)}\`);
|
|
|
- console.log(script.innerHTML)
|
|
|
|
|
document.body.appendChild(script)
|
|
document.body.appendChild(script)
|
|
|
`
|
|
`
|
|
|
chrome.tabs.executeScript(dataTemp.tabInfo.id, {code: execTwmp})
|
|
chrome.tabs.executeScript(dataTemp.tabInfo.id, {code: execTwmp})
|