Initial commit

This commit is contained in:
danial23 2024-01-14 20:39:42 -05:00
commit a1434db8f8
No known key found for this signature in database
8 changed files with 125 additions and 0 deletions

BIN
extension/icon128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
extension/icon16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

BIN
extension/icon32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
extension/icon48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

22
extension/manifest.json Normal file
View file

@ -0,0 +1,22 @@
{
"manifest_version": 3,
"name": "Effie's TikTok Extension",
"description": "Search words on Wiktionary.org",
"version": "0.1.0",
"minimum_chrome_version": "100",
"icons": {
"16": "icon16.png",
"32": "icon32.png",
"48": "icon48.png",
"128": "icon128.png"
},
"background": {
"service_worker": "service-worker.js",
"type": "module"
},
"action": {
"default_popup": "popup.html"
},
"permissions": ["cookies"],
"host_permissions": ["*://*.tiktok.com/*"]
}

34
extension/popup.html Normal file
View file

@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
}
.nickname {
padding: 10px;
max-width: 100px;
overflow-wrap: break-word;
}
.id {
padding: 10px;
max-width: 100px;
overflow-wrap: break-word;
}
</style>
</head>
<body>
<h3 style="width: 250px">People who don't follow you back:</h2>
<table id="table">
<tr>
<td><img src="" class="avatar" /></td>
<td class="nickname"></td>
<td class="id"><a href="" target="_blank"></a></td>
</tr>
</table>
<script type="module" src="popup.js"></script>
</body>
</html>

58
extension/popup.js Normal file
View file

@ -0,0 +1,58 @@
const table = document.getElementById("table");
const rowBlueprint = table.getElementsByTagName("tr")[0];
rowBlueprint.remove();
let token = "";
let maxCursor = new Date().getTime();
async function getToken() {
let msToken = "";
chrome.runtime.sendMessage(null, (response) => {
msToken = response;
});
while (!msToken) await new Promise((r) => setTimeout(r, 200));
token = msToken;
return msToken;
}
await getToken();
while (true) {
let responseText = await (
await fetch(
"https://www.tiktok.com/api/user/list/?" +
new URLSearchParams({
count: 199,
maxCursor: maxCursor,
minCursor: maxCursor - 2000000,
scene: 21,
msToken: token,
}),
)
).text();
let data = JSON.parse(responseText);
if ("userList" in data) {
for (const userData of data.userList) {
if (userData.user.relation == 2) continue;
addRow(userData.user);
}
maxCursor = data.minCursor;
} else break;
if (!data.hasMore) break;
}
function addRow(user) {
let row = rowBlueprint.cloneNode(true);
let cells = row.getElementsByTagName("td");
cells[0].getElementsByTagName("img")[0].src = user.avatarThumb;
cells[1].textContent = user.nickname;
let id = cells[2].getElementsByTagName("a")[0];
id.textContent = user.uniqueId;
id.href = "https://tiktok.com/@" + user.uniqueId;
table.appendChild(row);
}

View file

@ -0,0 +1,11 @@
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
chrome.cookies
.get({
url: "https://tiktok.com",
name: "msToken",
})
.then((cookie) => {
sendResponse(cookie.value);
});
return true;
});