-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
22 lines (19 loc) · 780 Bytes
/
popup.js
File metadata and controls
22 lines (19 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.addEventListener("DOMContentLoaded", () => {
const toggleSwitch = document.getElementById("toggleRTL");
// بارگذاری وضعیت ذخیرهشده
chrome.storage.sync.get(["rtlEnabled"], (result) => {
const isEnabled = result.rtlEnabled || false;
toggleSwitch.checked = isEnabled;
});
// وقتی سوئیچ تغییر کرد
toggleSwitch.addEventListener("change", () => {
const newState = toggleSwitch.checked;
// ذخیره وضعیت جدید
chrome.storage.sync.set({ rtlEnabled: newState }, () => {
// ارسال پیام به content script
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { rtlEnabled: newState });
});
});
});
});