Refactor Google Meet Transcripts Extension for Local Use
- Removed all cloud-related functionalities, including login prompts and token handling. - Disabled Laxis cloud features, ensuring no data is sent to external servers. - Updated manifest to reflect the new local-only functionality. - Added a new Python server to handle transcripts locally, including WebSocket support. - Implemented storage management for transcripts, including deduplication and file writing. - Created a smoke test for the WebSocket server to simulate transcript updates. - Updated README with setup instructions and usage details for the new local server.
This commit is contained in:
@@ -1,127 +1,35 @@
|
||||
// login.js — service worker افزونه.
|
||||
//
|
||||
// نسخهی پاکسازیشده: تمام ارتباط با laxis cloud حذف شده است.
|
||||
// دیگر هیچ توکنی دریافت نمیشود و هیچ transcript ای به سروری بیرون فرستاده نمیشود.
|
||||
// این ورکر فقط:
|
||||
// ۱) اسکریپتهای لازم (share, panel) و bridge محلی را import میکند،
|
||||
// ۲) چند مقدار وضعیتِ لوکال (meetingId / meetingName / username) را نگه میدارد،
|
||||
// ۳) bridge.js را بالا میآورد تا caption ها به سرور لوکال (ws://127.0.0.1:8765) برسند.
|
||||
|
||||
try {
|
||||
importScripts("config/share.js"), importScripts("config/panel.js")
|
||||
importScripts("config/share.js"), importScripts("config/panel.js"), importScripts("bridge.js")
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
let meetingId = null,
|
||||
transcriptId = null,
|
||||
meetingName = null,
|
||||
username = "";
|
||||
|
||||
chrome.storage.session.setAccessLevel({
|
||||
accessLevel: "TRUSTED_AND_UNTRUSTED_CONTEXTS"
|
||||
});
|
||||
const getTopics = (e, t) => fetch(`${domainUrl}/api/v2/templates/${e}/topics`, t);
|
||||
chrome.tabs.onRemoved.addListener(((e, t) => {
|
||||
chrome.storage.session.get(["sessionList"], (e => {
|
||||
if (e.sessionList) {
|
||||
let t = e.sessionList;
|
||||
console.log(t), chrome.storage.local.get(["token"], (e => {
|
||||
if (e.token) {
|
||||
let o = e.token;
|
||||
fetch(`${domainUrl}/api/v2/templates?quick-note=true`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${o}`,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}).then((e => {
|
||||
200 === e.status ? e.json().then((e => {
|
||||
e.items.length ? getTopics(e.items[0].id, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: `Bearer ${o}`,
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}).then((s => {
|
||||
s.json().then((s => {
|
||||
const n = s.items;
|
||||
let r = [];
|
||||
if (t.forEach((({
|
||||
image: e,
|
||||
person: t,
|
||||
text: o,
|
||||
startedAt: s,
|
||||
endedAt: i,
|
||||
highlight: a
|
||||
}) => {
|
||||
let c = [];
|
||||
if (a) {
|
||||
const e = bookmarkList.find((e => e.color === a[0]));
|
||||
if (e) {
|
||||
const t = n.find((t => t.color.toLowerCase() === e.code.toLowerCase()));
|
||||
t && (c = [t.id])
|
||||
}
|
||||
}
|
||||
o && r.push({
|
||||
imageUrl: e,
|
||||
person: "You" === t ? username : t,
|
||||
startedAt: s,
|
||||
endedAt: i || s,
|
||||
highlights: c,
|
||||
text: o
|
||||
})
|
||||
})), r.length) {
|
||||
let t = JSON.stringify({
|
||||
meetingId: meetingId,
|
||||
meetingName: meetingName,
|
||||
templateId: e.items[0].id,
|
||||
transcripts: r,
|
||||
isEnded: !0
|
||||
}),
|
||||
s = {
|
||||
Authorization: `Bearer ${o}`,
|
||||
"Content-Type": "application/json"
|
||||
};
|
||||
transcriptId ? fetch(`${domainUrl}/api/v1/speeches/google-meet/${transcriptId}`, {
|
||||
method: "PUT",
|
||||
headers: s,
|
||||
body: t
|
||||
}).then((e => {
|
||||
200 === e.status ? (console.log("save success"), chrome.tabs.create({
|
||||
url: `${domainUrl}/transcript/${transcriptId}`
|
||||
})) : 401 === e.status ? console.log("Expired token") : e.json().then((e => {
|
||||
console.log(e.message)
|
||||
}))
|
||||
})).catch((e => {
|
||||
console.log(e)
|
||||
})) : fetch(`${domainUrl}/api/v1/speeches/google-meet`, {
|
||||
method: "POST",
|
||||
headers: s,
|
||||
body: t
|
||||
}).then((e => {
|
||||
200 === e.status ? (chrome.tabs.create({
|
||||
url: `${domainUrl}/transcript/${transcriptId}`
|
||||
}), console.log("success")) : 401 === e.status ? console.log("Expired token") : e.json().then((e => {
|
||||
console.log(e.message)
|
||||
}))
|
||||
})).catch((e => {
|
||||
console.log(e)
|
||||
}))
|
||||
} else console.log("Empty transcript")
|
||||
}))
|
||||
})).catch((e => reject(e))) : console.log("No quick note template")
|
||||
})) : 401 === e.status ? console.log("Expired token") : e.json().then((e => console.log(e.message)))
|
||||
}))
|
||||
}
|
||||
}))
|
||||
}
|
||||
}))
|
||||
})), chrome.runtime.onMessage.addListener((e => {
|
||||
console.log(e), "meetingId" === e.type && (console.log(e.meetingId), meetingId = e.meetingId), "transcriptId" === e.type && (console.log(e.transcriptId), transcriptId = e.transcriptId), "meetingName" === e.type && (meetingName = e.meetingName), "username" === e.type && (username = e.data)
|
||||
})), chrome.runtime.onInstalled.addListener((e => {
|
||||
// e.reason === chrome.runtime.OnInstalledReason.INSTALL && chrome.tabs.create({
|
||||
// url: signupUrl
|
||||
// }, (function(e) {}))
|
||||
})), chrome.runtime.onMessageExternal.addListener((function(e, t, o) {
|
||||
t.origin === domainUrl && (o("extension received the token"), chrome.storage.local.set({
|
||||
token: e.token,
|
||||
refreshToken: e.refreshToken
|
||||
}, (function() {})), chrome.tabs.query({
|
||||
url: googleMeetUrl
|
||||
}, (function(t) {
|
||||
t[0] && chrome.tabs.sendMessage(t[0].id, {
|
||||
token: e.token,
|
||||
refreshToken: e.refreshToken
|
||||
}, (function(e) {}))
|
||||
})))
|
||||
})), chrome.runtime.setUninstallURL("https://www.laxis.tech/uninstall-survey");
|
||||
|
||||
// فقط نگهداشتن وضعیتِ لوکال؛ هیچ درخواست شبکهای انجام نمیشود.
|
||||
chrome.runtime.onMessage.addListener((e => {
|
||||
if (!e || !e.type) return;
|
||||
if ("meetingId" === e.type) meetingId = e.meetingId;
|
||||
else if ("transcriptId" === e.type) transcriptId = e.transcriptId;
|
||||
else if ("meetingName" === e.type) meetingName = e.meetingName;
|
||||
else if ("username" === e.type) username = e.data;
|
||||
}));
|
||||
|
||||
// در نسخهی laxis اینجا صفحهی signup باز میشد؛ حالا عمداً خالی است.
|
||||
chrome.runtime.onInstalled.addListener((() => {}));
|
||||
|
||||
Reference in New Issue
Block a user