Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
899f554336 | ||
|
|
7b5c3717ba |
1
build.sh
1
build.sh
@@ -2,4 +2,5 @@ rm build/ -rf
|
||||
mkdir -p ./build
|
||||
cd proxyserver && go build && mv proxyserver ../build/ && cd ..
|
||||
cp start.sh build/start.sh
|
||||
cp stop.sh build/stop.sh
|
||||
cp proxyserver/config.yaml build/config.yaml
|
||||
|
||||
1
chromeproxy/.vscode/launch.json
vendored
1
chromeproxy/.vscode/launch.json
vendored
@@ -14,6 +14,7 @@
|
||||
"--ignore-certificate-errors",
|
||||
"--disable-dev-shm-usage",
|
||||
"--mute-audio",
|
||||
"--single-process",
|
||||
"--safebrowsing-disable-auto-update",
|
||||
"--disable-gpu",
|
||||
"--no-sandbox",
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
|
||||
var href = window.location.href;
|
||||
var content = document.documentElement.innerHTML;
|
||||
|
||||
setTimeout(function(){
|
||||
window.close();
|
||||
}, 15000)
|
||||
try {
|
||||
if(waittime === undefined) {
|
||||
waittime = 6000
|
||||
}
|
||||
} catch (error) {
|
||||
waittime = 6000
|
||||
}
|
||||
|
||||
|
||||
if (condition == undefined) {
|
||||
condition = function () {
|
||||
@@ -12,11 +16,17 @@ if (condition == undefined) {
|
||||
};
|
||||
}
|
||||
|
||||
if (condition()) {
|
||||
Tell(BackgroundMsgType.CONTENT, content);
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
if (condition()) {
|
||||
Tell(BackgroundMsgType.CONTENT, content);
|
||||
} else {
|
||||
Tell(BackgroundMsgType.NOTWANT, content);
|
||||
}
|
||||
}, waittime)
|
||||
}
|
||||
|
||||
function Tell(backgroundType, content) {
|
||||
try {
|
||||
|
||||
@@ -16,7 +16,15 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
|
||||
GetTask(sender);
|
||||
break;
|
||||
case BackgroundMsgType.NOTWANT:
|
||||
|
||||
task = task_manager[sender.tab.id];
|
||||
task.data.retry --;
|
||||
if(task.data.retry >= 0) {
|
||||
CaptureContent(task);
|
||||
} else {
|
||||
ErrorTask(sender, request.content);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -27,6 +35,7 @@ function GetTask(sender) {
|
||||
fetch(GetTaskUrl).then(function (response) {
|
||||
if (response.ok) {
|
||||
response.json().then(function (task) {
|
||||
|
||||
CaptureContent(task);
|
||||
})
|
||||
} else {
|
||||
@@ -41,6 +50,11 @@ function GetTask(sender) {
|
||||
|
||||
function CaptureContent(task) {
|
||||
if (task.code == 200) {
|
||||
|
||||
if(task.data.retry == undefined) {
|
||||
task.data.retry = 1;
|
||||
}
|
||||
|
||||
chrome.tabs.create({ url: task.data.url }, function (tab) {
|
||||
task_manager[tab.id] = task;
|
||||
if (task.data.content_condition) {
|
||||
@@ -60,8 +74,10 @@ function CaptureContent(task) {
|
||||
function FinishTask(sender, content) {
|
||||
var task = task_manager[sender.tab.id];
|
||||
var formdata = new FormData();
|
||||
|
||||
formdata.append("taskid", task.data.taskid);
|
||||
formdata.append("content", content);
|
||||
|
||||
delete task_manager[sender.tab.id];
|
||||
chrome.tabs.remove(sender.tab.id);
|
||||
fetch(FinishTaskUrl, { method: "POST", body: formdata }).then(function (response) {
|
||||
|
||||
@@ -3,6 +3,10 @@ if(href.startsWith(Host)) {
|
||||
setInterval(function(){
|
||||
GetTask();
|
||||
}, 1);
|
||||
} else {
|
||||
setTimeout(function(){
|
||||
close();
|
||||
}, 15000)
|
||||
}
|
||||
|
||||
function GetTask() {
|
||||
|
||||
@@ -19,7 +19,6 @@ func CallbackServer(task *Task) {
|
||||
defer task.lock.Unlock()
|
||||
if callback, ok := task.data["callback"]; ok {
|
||||
cburl := callback.(string)
|
||||
// log.Println(cburl)
|
||||
_, err := requests.NewSession().Post(cburl).SetBodyAuto(task.data, requests.TypeFormData).Execute()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
||||
@@ -4,7 +4,7 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/474420502/focus v0.12.0
|
||||
github.com/474420502/requests v1.10.0
|
||||
github.com/474420502/requests v1.10.1
|
||||
github.com/bwmarrin/snowflake v0.3.0
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/go-playground/validator/v10 v10.4.1 // indirect
|
||||
|
||||
@@ -3,6 +3,8 @@ github.com/474420502/focus v0.12.0 h1:+icbmj7IEOefvTegHt5EpcHt6WFbe2miIrceUJx2Ev
|
||||
github.com/474420502/focus v0.12.0/go.mod h1:d0PMjtMxFz1a9HIhwyFPkWa+JF+0LgOrEUfd8iZka6s=
|
||||
github.com/474420502/requests v1.10.0 h1:Oz7+Nx+1iuJJUjbBH3cVmkDVosF2tyq5d72TMAoQH8I=
|
||||
github.com/474420502/requests v1.10.0/go.mod h1:SB8/RIUVWF3AGotuq/mATUwAjXzzlV7iWaBNM3+c06c=
|
||||
github.com/474420502/requests v1.10.1 h1:k5qK8ZWPIdrG0EurJuK2hhoYFbJ9GJTe0xvrzESMFLo=
|
||||
github.com/474420502/requests v1.10.1/go.mod h1:SB8/RIUVWF3AGotuq/mATUwAjXzzlV7iWaBNM3+c06c=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Pallinder/go-randomdata v1.1.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
|
||||
@@ -70,14 +70,21 @@ func PutTask(c *gin.Context) {
|
||||
now := time.Now()
|
||||
tid := snowNode.Generate().Base64()
|
||||
label := c.PostForm("label")
|
||||
|
||||
if carrayhash := c.PostForm("carrayhash"); carrayhash != "" {
|
||||
data.Store("carrayhash", carrayhash)
|
||||
}
|
||||
|
||||
if callback := c.PostForm("callback"); callback != "" {
|
||||
data.Store("callback", callback)
|
||||
}
|
||||
|
||||
data.Store("taskid", tid)
|
||||
data.Store("url", u)
|
||||
data.Store("ts", now.UnixNano())
|
||||
data.Store("label", label)
|
||||
data.Store("content_condition", c.PostForm("content_condition"))
|
||||
if callback := c.PostForm("callback"); callback != "" {
|
||||
data.Store("callback", callback)
|
||||
}
|
||||
|
||||
taskQueue.Push(tid, data)
|
||||
oplog.Write(data)
|
||||
c.JSON(http.StatusOK, Response{Code: 200, Message: "ok", Data: data})
|
||||
|
||||
Reference in New Issue
Block a user