-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
2,597 additions
and
425 deletions.
There are no files selected for viewing
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { sharePostToGroup } from "./popup/helpers/facebook.js"; | ||
import { randInt } from "./popup/helpers/utils.js"; | ||
|
||
console.log("background"); | ||
|
||
const logs = []; | ||
const sharePostToGroups = [ | ||
// { | ||
// postUrl: "https://www.facebook.com/share/p/1phXqQ8TvxniRVsi/", | ||
// caption: "", | ||
// groups: [ | ||
// "https://www.facebook.com/groups/311528245988035", | ||
// "311528245988035", | ||
// ], | ||
// waitMin: 5000, | ||
// waitMax: 20000, | ||
// timer: "2024-09-08T21:06", | ||
// }, | ||
]; | ||
|
||
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { | ||
if (request.action === "get_sharePostToGroups") { | ||
sendResponse(sharePostToGroups); | ||
} else if (request.action === "add_sharePostToGroups") { | ||
sharePostToGroups.push(request.data); | ||
sendResponse(sharePostToGroups); | ||
} else if (request.action === "remove_sharePostToGroups") { | ||
sharePostToGroups.splice(request.data?.index, 1); | ||
sendResponse(sharePostToGroups); | ||
} else if (request.action === "get_logs") { | ||
sendResponse(logs); | ||
} else if (request.action === "clear_logs") { | ||
logs.length = 0; | ||
sendResponse(logs); | ||
} | ||
}); | ||
|
||
function addLog(log) { | ||
logs.push({ | ||
time: Date.now(), | ||
log: log, | ||
}); | ||
} | ||
|
||
setInterval(() => { | ||
for (let i = 0; i < sharePostToGroups.length; i++) { | ||
let job = sharePostToGroups[i]; | ||
|
||
if (job.done || job.sharing) continue; | ||
|
||
if (job.running) { | ||
// sharing | ||
if ( | ||
!job.nextShareTime || | ||
Date.now() > new Date(job.nextShareTime).getTime() | ||
) { | ||
let groupUrl = job.groups[job.shareIndex]; | ||
job.sharing = true; | ||
sharePostToGroup({ | ||
postUrl: job.postUrl, | ||
groupUrl: groupUrl, | ||
note: job.caption || "", | ||
}) | ||
.then((sharedUrl) => { | ||
console.log("share", groupUrl, job, sharedUrl); | ||
job.sharedUrls[job.shareIndex] = sharedUrl; | ||
addLog( | ||
`SHARE ${job.shareIndex + 1}/${job.groups.length}: shared ${ | ||
job.postUrl | ||
} to ${groupUrl} => ${sharedUrl}` | ||
); | ||
}) | ||
.catch((e) => { | ||
console.log(e); | ||
addLog( | ||
`FAIL SHARE ${job.shareIndex + 1}/${job.groups.length}: share ${ | ||
job.postUrl | ||
} to ${groupUrl} failed ${e.message}` | ||
); | ||
}) | ||
.finally(() => { | ||
job.shareIndex++; | ||
// check done | ||
if (job.shareIndex > job.groups.length - 1) { | ||
job.running = false; | ||
job.done = Date.now(); | ||
addLog( | ||
`DONE: share ${job.postUrl} to ${job.groups.length} groups` | ||
); | ||
} else { | ||
job.nextShareTime = | ||
Date.now() + randInt(job.waitMin, job.waitMax); | ||
} | ||
job.sharing = false; | ||
}); | ||
} | ||
|
||
continue; | ||
} | ||
|
||
// check start running | ||
if (Date.now() > new Date(job.timer).getTime()) { | ||
job.running = true; | ||
job.shareIndex = 0; | ||
job.sharedUrls = Array(job.groups.length).fill(""); | ||
addLog( | ||
`START: share ${job.postUrl} to ${ | ||
job.groups.length | ||
} groups: ${job.groups.join(", ")}` | ||
); | ||
} | ||
} | ||
}, 1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Facebook Group Extension", | ||
"description": "Quản lý nhóm facebook", | ||
"version": "1.0", | ||
"action": { | ||
"default_popup": "./popup/index.html" | ||
}, | ||
"icons": { | ||
"16": "assets/icon_default_16.png", | ||
"48": "assets/icon_default_48.png", | ||
"128": "assets/icon_default_128.png" | ||
}, | ||
"background": { | ||
"service_worker": "background.js", | ||
"type": "module" | ||
}, | ||
"permissions": [ | ||
"tabs", | ||
"cookies", | ||
"scripting", | ||
"declarativeNetRequest", | ||
"declarativeNetRequestFeedback", | ||
"declarativeNetRequestWithHostAccess" | ||
], | ||
"host_permissions": ["*://*/*", "<all_urls>"], | ||
"declarative_net_request": { | ||
"rule_resources": [ | ||
{ | ||
"id": "ruleset_1", | ||
"enabled": true, | ||
"path": "./rules.json" | ||
} | ||
] | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
scripts/backup/ext/fb-auto-invite-share/popup/auto_invite_like_page/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Facebook Tools</title> | ||
|
||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
|
||
<body> | ||
<h1>Tự động mời like page</h1> | ||
|
||
<div class="input-container"> | ||
<h3>Thời gian chờ (giây):</h3> | ||
<span><i>(ngẫu nhiên trong khoảng)</i></span><br /> | ||
<div class="input-row"> | ||
<input type="number" min="0" value="5" id="inputWaitMin" /> ➡️ <input type="number" min="0" value="20" | ||
id="inputWaitMax" /> | ||
</div> | ||
</div> | ||
|
||
<h3>Mời tối đa bao nhiêu người?</h3> | ||
<span><i>(nhập 0 để mời hết)</i></span><br /> | ||
<input type="number" id="max-people" value="10"> | ||
|
||
<button class="button" id="start-btn">Bắt đầu</button> | ||
|
||
<script src="main.js"></script> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.