aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2025-06-15 22:58:32 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2025-06-15 22:58:32 +0530
commit920c4837acbba57fb1c51941770586c89436bc61 (patch)
treeadab786c0b6ef869ee7c062bb3affdda7b43ace3 /src/shared
parent8b7f56048cb8dce1cd41225a059b82b1e782299b (diff)
downloadbanglar-bhumi-utils-920c4837acbba57fb1c51941770586c89436bc61.tar.gz
banglar-bhumi-utils-920c4837acbba57fb1c51941770586c89436bc61.zip
Updated README.md + Some minor changes.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/generate-web-page.ts15
-rw-r--r--src/shared/intercept-jquery-ajax.ts4
-rw-r--r--src/shared/modify-dom.ts2
-rw-r--r--src/shared/observe-dom.ts2
-rw-r--r--src/shared/script-injector.ts2
-rw-r--r--src/shared/styling.ts2
6 files changed, 14 insertions, 13 deletions
diff --git a/src/shared/generate-web-page.ts b/src/shared/generate-web-page.ts
index 1771e15..a07575f 100644
--- a/src/shared/generate-web-page.ts
+++ b/src/shared/generate-web-page.ts
@@ -1,10 +1,11 @@
-export const generateWebPage = (content: string, title: string = "Banglar Bhumi") => {
+export function generateWebPage(content: string, title: string = "Banglar Bhumi") {
const tab = window.open("about:blank", "_blank");
-
- if (tab) {
- tab.document.write(content);
- tab.document.close();
- tab.document.title = title;
- tab.focus();
+ if (!tab) {
+ return;
}
+
+ tab.document.write(content);
+ tab.document.close();
+ tab.document.title = title;
+ tab.focus();
};
diff --git a/src/shared/intercept-jquery-ajax.ts b/src/shared/intercept-jquery-ajax.ts
index efcb555..a77dd44 100644
--- a/src/shared/intercept-jquery-ajax.ts
+++ b/src/shared/intercept-jquery-ajax.ts
@@ -32,10 +32,10 @@ document.addEventListener("DOMContentLoaded", () => {
};
});
-export const interceptPost = (url: string, callback: InterceptJqueryAjaxCallback) => {
+export function interceptPost(url: string, callback: InterceptJqueryAjaxCallback) {
postIntercepts.push({ url, callback });
};
-export const interceptGet = (url: string, callback: InterceptJqueryAjaxCallback) => {
+export function interceptGet(url: string, callback: InterceptJqueryAjaxCallback) {
getIntercepts.push({ url, callback });
};
diff --git a/src/shared/modify-dom.ts b/src/shared/modify-dom.ts
index 21dfab0..22b8e8e 100644
--- a/src/shared/modify-dom.ts
+++ b/src/shared/modify-dom.ts
@@ -45,6 +45,6 @@ observeDOM(() => {
return false;
});
-export const modifyDOM = (modificationRules: DOMModificationRules) => {
+export function modifyDOM(modificationRules: DOMModificationRules) {
domModificationRules = domModificationRules.concat(modificationRules);
};
diff --git a/src/shared/observe-dom.ts b/src/shared/observe-dom.ts
index 37bcfcd..e82ce1e 100644
--- a/src/shared/observe-dom.ts
+++ b/src/shared/observe-dom.ts
@@ -24,6 +24,6 @@ observer.observe(document, {
subtree: true
});
-export const observeDOM = (callback: ObserveDOMCallback) => {
+export function observeDOM(callback: ObserveDOMCallback) {
callbacks.push(callback);
};
diff --git a/src/shared/script-injector.ts b/src/shared/script-injector.ts
index a2139c7..697c8d6 100644
--- a/src/shared/script-injector.ts
+++ b/src/shared/script-injector.ts
@@ -2,7 +2,7 @@ type DataType = {
[key: string]: string
};
-export const injectScriptHead = (src: string, data: DataType = {}) => {
+export function injectScriptHead(src: string, data: DataType = {}) {
const s = document.createElement("script") as HTMLScriptElement;
s.src = chrome.runtime.getURL(src);
for (const i in data) {
diff --git a/src/shared/styling.ts b/src/shared/styling.ts
index 3ec25c8..759fecb 100644
--- a/src/shared/styling.ts
+++ b/src/shared/styling.ts
@@ -1,4 +1,4 @@
-export const styles = (selector: string, styles: { [key: string]: string }) => {
+export function styles(selector: string, styles: Record<string, string>) {
const elements = Array.from(document.querySelectorAll(selector)) as HTMLElement[];
for (const element of elements) {