|
|
@@ -46,7 +46,8 @@ function creatToday(fileList) {
|
|
|
}
|
|
|
const fileData = {
|
|
|
filename: getDaysAgo(0) + '.csv',
|
|
|
- content: arrayToCSV(fileList)
|
|
|
+ content: arrayToCSV(fileList),
|
|
|
+ encoding: "gb2312"
|
|
|
};
|
|
|
|
|
|
// 调用保存方法
|
|
|
@@ -64,7 +65,8 @@ function saveFile(adtaArr, next) {
|
|
|
// 保存数据
|
|
|
const fileData = {
|
|
|
filename: getDaysAgo(0) + '.csv',
|
|
|
- content: arrayToCSV(adtaArr)
|
|
|
+ content: arrayToCSV(adtaArr),
|
|
|
+ encoding: "gb2312"
|
|
|
};
|
|
|
|
|
|
// 调用保存方法
|
|
|
@@ -100,6 +102,34 @@ function cutString (original, before, after, index) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function checkText () {
|
|
|
+ if (window.noRun) return
|
|
|
+ if (document.querySelector('.style-scope.ytd-about-channel-renderer') || document.querySelector('ytm-about-channel-renderer').innerText) {
|
|
|
+ window.noRun = true
|
|
|
+ let pdInfo = document.querySelector('.style-scope.ytd-about-channel-renderer').innerText
|
|
|
+ if (!pdInfo) {
|
|
|
+ pdInfo = document.querySelector('ytm-about-channel-renderer').innerText
|
|
|
+ }
|
|
|
+ let bfsl = parseInt(cutString(pdInfo,'视频\n\n\t', '次观看'))
|
|
|
+ let spsl = parseInt(cutString(pdInfo,'订阅者\n\n\t', '个视频'))
|
|
|
+ let dyrs = parseInt(cutString(pdInfo,'注册\n\n\t', '位订阅者'))
|
|
|
+ if (!spsl) {
|
|
|
+ spsl = parseInt(cutString(pdInfo,'注册\n', '个视频'))
|
|
|
+ }
|
|
|
+ bfsl = bfsl ? bfsl : 0
|
|
|
+ spsl = spsl ? spsl : 0
|
|
|
+ dyrs = dyrs ? dyrs : 0
|
|
|
+ console.log(bfsl, spsl, dyrs)
|
|
|
+ adtaArr[index][5] = bfsl
|
|
|
+ adtaArr[index][6] = spsl
|
|
|
+ adtaArr[index][7] = dyrs
|
|
|
+ adtaArr[index][8] = bfsl - parseInt(adtaArr[index][2])
|
|
|
+ adtaArr[index][9] = spsl - parseInt(adtaArr[index][3])
|
|
|
+ adtaArr[index][10] = dyrs - parseInt(adtaArr[index][4])
|
|
|
+ saveFile(adtaArr, true)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function checkData (adtaArr) {
|
|
|
for (let index = 0; index < adtaArr.length; index++) {
|
|
|
const element = adtaArr[index];
|
|
|
@@ -110,22 +140,14 @@ function checkData (adtaArr) {
|
|
|
setTimeout(() => {
|
|
|
document.querySelector('.yt-truncated-text__absolute-button').click()
|
|
|
setTimeout(() => {
|
|
|
- let pdInfo = document.querySelector('.style-scope.ytd-about-channel-renderer').innerText
|
|
|
- let bfsl = parseInt(cutString(pdInfo,'视频\n\n\t', '次观看'))
|
|
|
- let spsl = parseInt(cutString(pdInfo,'订阅者\n\n\t', '个视频'))
|
|
|
- let dyrs = parseInt(cutString(pdInfo,'注册\n\n\t', '位订阅者'))
|
|
|
- bfsl = bfsl ? bfsl : 0
|
|
|
- spsl = spsl ? spsl : 0
|
|
|
- dyrs = dyrs ? dyrs : 0
|
|
|
- console.log(bfsl, spsl, dyrs)
|
|
|
- adtaArr[index][5] = bfsl
|
|
|
- adtaArr[index][6] = spsl
|
|
|
- adtaArr[index][7] = dyrs
|
|
|
- adtaArr[index][8] = bfsl - parseInt(adtaArr[index][2])
|
|
|
- adtaArr[index][9] = spsl - parseInt(adtaArr[index][3])
|
|
|
- adtaArr[index][10] = dyrs - parseInt(adtaArr[index][4])
|
|
|
- saveFile(adtaArr, true)
|
|
|
+ checkText()
|
|
|
}, 3000);
|
|
|
+ setTimeout(() => {
|
|
|
+ checkText()
|
|
|
+ }, 8000);
|
|
|
+ setTimeout(() => {
|
|
|
+ location.reload()
|
|
|
+ }, 14000);
|
|
|
}, 2000);
|
|
|
} else {
|
|
|
location.href = element[1]
|
|
|
@@ -162,12 +184,12 @@ function checkData (adtaArr) {
|
|
|
|
|
|
|
|
|
// 调用保存方法
|
|
|
-window.electronAPI.readFile({filename: getDaysAgo(0) + '.csv', encoding: "utf8"}).then(result => {
|
|
|
+window.electronAPI.readFile({filename: getDaysAgo(0) + '.csv', encoding: "gb2312"}).then(result => {
|
|
|
if (result.success) {
|
|
|
console.log(result.content);
|
|
|
// 如果内容是空的,则读取昨天的
|
|
|
if (result.content == '') {
|
|
|
- window.electronAPI.readFile({filename: getDaysAgo(1) + '.csv', encoding: "utf8"}).then(result2 => {
|
|
|
+ window.electronAPI.readFile({filename: getDaysAgo(1) + '.csv', encoding: "gb2312"}).then(result2 => {
|
|
|
if (result2.success) {
|
|
|
console.log(result2.content);
|
|
|
// 如果内容是空的,则读取昨天的
|