|
|
@@ -33,82 +33,80 @@ function createWindow () {
|
|
|
mainWindow.loadURL('http://cunchu.site/work/debug/index.html')
|
|
|
mainWindow.webContents.on("dom-ready", function() {
|
|
|
mainWindow.webContents.executeJavaScript(`
|
|
|
- window.owoedition = 1
|
|
|
- window.owoPC = true
|
|
|
- function loadScript(url, callback) {
|
|
|
- var script = document.createElement("script")
|
|
|
- script.type = "text/javascript";
|
|
|
- if (script.readyState) { //IE
|
|
|
- script.onreadystatechange = function () {
|
|
|
- if (script.readyState == "loaded" || script.readyState == "complete") {
|
|
|
- script.onreadystatechange = null;
|
|
|
- if (callback) callback();
|
|
|
- }
|
|
|
- };
|
|
|
- } else { //Others
|
|
|
- script.onload = function () {
|
|
|
- if (callback) callback();
|
|
|
- };
|
|
|
- }
|
|
|
- script.src = url;
|
|
|
- var head = document.head || document.getElementsByTagName('head')[0];
|
|
|
- head.appendChild(script);
|
|
|
- }
|
|
|
- function loadCSS (url) {
|
|
|
- var link = document.createElement("link");
|
|
|
- link.rel = "stylesheet";
|
|
|
- link.type = "text/css";
|
|
|
- link.href = url;
|
|
|
- document.getElementsByTagName("head")[0].appendChild(link);
|
|
|
+ var owoApp = 2
|
|
|
+ window.owoPC = true
|
|
|
+ function loadScript(url, callback) {
|
|
|
+ var script = document.createElement("script")
|
|
|
+ script.type = "text/javascript";
|
|
|
+ if (script.readyState) { //IE
|
|
|
+ script.onreadystatechange = function () {
|
|
|
+ if (script.readyState == "loaded" || script.readyState == "complete") {
|
|
|
+ script.onreadystatechange = null;
|
|
|
+ if (callback) callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ } else { //Others
|
|
|
+ script.onload = function () {
|
|
|
+ if (callback) callback();
|
|
|
+ };
|
|
|
}
|
|
|
- // 拦截请求
|
|
|
- loadScript('//cunchu.site/work/assist/ajaxhook.min.js')
|
|
|
- let needLoad = localStorage.getItem('needLoad')
|
|
|
- needLoad = null
|
|
|
- function owoReload (data) {
|
|
|
- data.forEach(element => {
|
|
|
- if (element.type == 'app') {
|
|
|
- let scriptList = element.script
|
|
|
- if (typeof scriptList == 'string') {
|
|
|
- scriptList = JSON.parse(scriptList)
|
|
|
- }
|
|
|
- if (typeof element.style == 'string') {
|
|
|
- element.style = JSON.parse(element.style)
|
|
|
- }
|
|
|
- scriptList.forEach(scriptItem => {
|
|
|
- loadScript(scriptItem)
|
|
|
- });
|
|
|
- element.style.forEach(styleItem => {
|
|
|
- loadCSS(styleItem)
|
|
|
- });
|
|
|
+ script.src = url;
|
|
|
+ var head = document.head || document.getElementsByTagName('head')[0];
|
|
|
+ head.appendChild(script);
|
|
|
+ }
|
|
|
+ function loadCSS (url) {
|
|
|
+ var link = document.createElement("link");
|
|
|
+ link.rel = "stylesheet";
|
|
|
+ link.type = "text/css";
|
|
|
+ link.href = url;
|
|
|
+ document.getElementsByTagName("head")[0].appendChild(link);
|
|
|
+ }
|
|
|
+ // 拦截请求
|
|
|
+ loadScript('//cunchu.site/work/assist/ajaxhook.min.js')
|
|
|
+ let needLoad = localStorage.getItem('needLoad')
|
|
|
+ needLoad = null
|
|
|
+ function owoReload (data) {
|
|
|
+ data.forEach(element => {
|
|
|
+ if (element.type == 'app') {
|
|
|
+ let scriptList = element.script
|
|
|
+ if (typeof scriptList == 'string') {
|
|
|
+ scriptList = JSON.parse(scriptList)
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- if (needLoad) {
|
|
|
-
|
|
|
- owoReload(JSON.parse(needLoad))
|
|
|
- } else {
|
|
|
- fetch("https://going.run/assist?route=app", {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- "Content-Type": "application/json"
|
|
|
- },
|
|
|
- body: JSON.stringify({
|
|
|
- "url": location.href,
|
|
|
- "edition": 1
|
|
|
- }),
|
|
|
- redirect: 'follow'
|
|
|
- }).then(response => response.json())
|
|
|
- .then(result => {
|
|
|
- if (result['err'] == 0) {
|
|
|
- owoReload(result['data'])
|
|
|
- localStorage.setItem('needLoad', JSON.stringify(result['data']))
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(error => console.log('error', error))
|
|
|
- }
|
|
|
- // loadScript('//cunchu.site/work/script/chxy.js')
|
|
|
+ if (typeof element.style == 'string') {
|
|
|
+ element.style = JSON.parse(element.style)
|
|
|
+ }
|
|
|
+ scriptList.forEach(scriptItem => {
|
|
|
+ loadScript(scriptItem)
|
|
|
+ });
|
|
|
+ element.style.forEach(styleItem => {
|
|
|
+ loadCSS(styleItem)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (needLoad) {
|
|
|
+ owoReload(JSON.parse(needLoad))
|
|
|
+ } else {
|
|
|
+ fetch("https://going.run/assist?route=app", {
|
|
|
+ method: 'POST',
|
|
|
+ headers: {
|
|
|
+ "Content-Type": "application/json"
|
|
|
+ },
|
|
|
+ body: JSON.stringify({
|
|
|
+ "url": location.href,
|
|
|
+ "edition": 1
|
|
|
+ }),
|
|
|
+ redirect: 'follow'
|
|
|
+ }).then(response => response.json())
|
|
|
+ .then(result => {
|
|
|
+ if (result['err'] == 0) {
|
|
|
+ owoReload(result['data'])
|
|
|
+ localStorage.setItem('needLoad', JSON.stringify(result['data']))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => console.log('error', error))
|
|
|
+ }
|
|
|
`);
|
|
|
});
|
|
|
// Open the DevTools.
|