30 May 2023 |
thehouseoffreacks | ooooohhh | 03:55:38 |
thehouseoffreacks | so then in one file I put a function | 03:55:43 |
DoctorCringe | browser.runtime.onMessage.addListener((message, sender) => {
const tabId = sender.tab.id;
const subject = message.subject;
const action = message.action;
console.debug("Tab: " + tabId + " - Received Message: '" + JSON.stringify(message) + "'");
if (subject === "NetworkRequests") {
if (action === "block" && unblockedTabs.includes(tabId))
unblockedTabs.splice(unblockedTabs.indexOf(tabId), 1);
else if (action === "unblock" && !unblockedTabs.includes(tabId))
unblockedTabs.push(tabId);
}
}); | 03:55:45 |
thehouseoffreacks | and then another i put the listner | 03:55:46 |
DoctorCringe | like i have a listener in a background script like this | 03:55:55 |
DoctorCringe | so the background script can block certain network requests until the content script says "ok, allow things through" | 03:56:28 |
DoctorCringe | they talk back and forth through browser.runtime.onMessage | 03:56:44 |
DoctorCringe | and browser.runtime.sendMessage | 03:57:12 |
thehouseoffreacks | I will try to setup a git repo and put all the files I have there | 03:57:32 |
DoctorCringe | its basically so the browser wide script can communicate with the tab specific scripts | 03:57:39 |
thehouseoffreacks | wholly molly | 03:57:51 |
DoctorCringe | yeah its kind of different than typical website javascript until you get used to it | 03:58:13 |
DoctorCringe | but you realize its very necessary that it works this way once you see how extensions work | 03:58:46 |
DoctorCringe | i recommend you clone the example extension repo and look at the code in whatever editor you use | 03:59:07 |
DoctorCringe | its good to look at that code | 03:59:13 |
DoctorCringe | helpful | 03:59:15 |
thehouseoffreacks | allright | 03:59:30 |
DoctorCringe | its a lot of information to take in all at once because the flow is so different from website javascript files | 03:59:46 |
thehouseoffreacks | but most of their examples do something different than what I want to do | 03:59:48 |
thehouseoffreacks | getting used to website javascript files was hard enouph | 04:00:02 |
thehouseoffreacks | (at least for me) | 04:00:11 |
DoctorCringe | i honestly dont remember its been so many years now lol | 04:00:20 |
DoctorCringe | it was so long ago | 04:00:24 |
DoctorCringe | and javascript was so different back then | 04:00:36 |
DoctorCringe | honestly none of the example extensions are going to do what anyone wants to do they just demonstrate various techniques you need to use | 04:01:12 |
thehouseoffreacks | https://codeberg.org/zortazert/github-pages | 04:02:51 |
31 May 2023 |
| DeathStroke19891 joined the room. | 05:07:56 |
1 Jun 2023 |
| Watanabe joined the room. | 01:18:58 |
| Watanabe joined the room. | 01:19:25 |
| Colemak joined the room. | 05:22:07 |