Skip to content

Commit ceba401

Browse files
committed
feat(chrome_extension): setup & cleanup
Signed-off-by: Aryan Goyal <[email protected]>
1 parent 94db499 commit ceba401

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed
File renamed without changes.
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<script lang="ts">
2-
const getUrl = async () => {
3-
const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
4-
console.log(tab.url);
5-
};
6-
72
const getCode = async () => {
83
const [tab] = await chrome.tabs.query({ active: true, lastFocusedWindow: true });
9-
console.log(tab.id)
10-
if (tab.id === undefined) {
11-
}
4+
console.log(tab.id);
5+
126
chrome.scripting.executeScript({
137
target: { tabId: tab.id },
14-
func: () => {
15-
if (window.monaco) {
16-
console.log('got it');
17-
} else {
18-
console.log('nope, cant see');
19-
}
20-
}
8+
world: 'MAIN',
9+
func: (url: string | undefined) => {
10+
const lg = window.monaco?.editor?.getModels()[0].getLanguageId();
11+
const code = window.monaco?.editor?.getModels()[0].getValue();
12+
console.log(url);
13+
console.log(lg, code);
14+
},
15+
args: [tab.url]
2116
});
17+
18+
chrome.runtime.sendMessage(
19+
{ method: 'getLocalStorage', key: 'lc-curr-code' },
20+
function (response) {
21+
console.log(response.data);
22+
}
23+
);
2224
};
2325
</script>
2426

25-
<h1>Welcome to SvelteKit</h1>
26-
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
27-
<button on:click={getUrl}>Get url</button>
27+
<h1>Socratic Code</h1>
2828
<button on:click={getCode}>Get code</button>

extension/chromium/socratic-code/static/manifest.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@
1212
"default_title": "Socratic Code",
1313
"default_popup": "index.html"
1414
},
15-
"permissions": ["activeTab", "tabs", "scripting"]
15+
"permissions": ["activeTab", "tabs", "scripting", "storage"],
16+
"host_permissions": ["https://leetcode.com/*", "https://*.leetcode.com/*"],
17+
"background": {
18+
"service_worker": "service_worker.js",
19+
"type": "module"
20+
}
1621
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('service-worker');

0 commit comments

Comments
 (0)