Skip to content

Commit bd6ee29

Browse files
authored
Merge pull request #22 from husamahmud/feature/16/work-with-database-problems
Merge PR22
2 parents 54d8fd2 + f28a16d commit bd6ee29

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

background.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
44
target: { tabId: tabId },
55
func: async () => {
66
let probNameElement, probName, probNum, solution, formattedSolution,
7-
fileEx, runtimeText, memoryText, commitMsg, fileName, solutionsId;
7+
fileEx, runtimeText, memoryText, queryRuntimeText, commitMsg,
8+
fileName, solutionsId;
89
const fileExs = {
910
"C": ".c",
1011
"C++": ".cpp",
@@ -25,6 +26,11 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
2526
"Scala": ".scala",
2627
"Swift": ".swift",
2728
"TypeScript": ".ts",
29+
"MySQL": ".sql",
30+
"PostgreSQL": ".sql",
31+
"Oracle": ".sql",
32+
"MS SQL Server": ".tsql",
33+
"Pandas": ".py",
2834
};
2935
const localStorageExs = {
3036
"C": "c",
@@ -46,7 +52,13 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
4652
"Scala": "scala",
4753
"Swift": "swift",
4854
"TypeScript": "typeScript",
55+
"MySQL": "mysql",
56+
"Oracle": "oraclesql",
57+
"PostgreSQL": "postgresql",
58+
"MS SQL Server": "mssql",
59+
"Pandas": "pythondata",
4960
};
61+
const dbs = ["MySQL", "Oracle", "PostgreSQL", "MS SQL Server", "Pandas"];
5062

5163
/** Select problem name *************************************/
5264
probNameElement = document.querySelector(`div.flex.items-start.justify-between.gap-4 > div.flex.items-start.gap-2 > div > a`);
@@ -64,19 +76,27 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
6476
solution = localStorage.getItem(`${probNum}_${solutionsId}_${localStorageExs[solutionLangText]}`);
6577
await checkSolInLocalStorage(solution);
6678
/** Generate the file name ********************************/
67-
if (solutionLangText)
68-
fileEx = fileExs[solutionLangText];
79+
if (solutionLangText) fileEx = fileExs[solutionLangText];
6980
fileName = `${probName}${fileEx}`;
7081
await sessionStorage.setItem("fileName", fileName);
7182
/** Select the mem&runtime ********************************/
72-
const [runtime, memory] = document.querySelectorAll("div.flex.items-center.justify-between.gap-2 > div > div.rounded-sd.flex.min-w-\\[275px\\].flex-1.cursor-pointer.flex-col.px-4.py-3.text-xs > div:nth-child(3) > span.font-semibold");
73-
if (runtime && memory) {
74-
runtimeText = runtime.innerText;
75-
memoryText = memory.innerText;
83+
let runtime, memory, queryRuntime;
84+
if (dbs.includes(solutionLangText)) {
85+
queryRuntime = document.querySelector("div.flex.items-center.justify-between.gap-2 > div > div.rounded-sd.flex.min-w-\\[275px\\].flex-1.cursor-pointer.flex-col.px-4.py-3.text-xs > div:nth-child(3) > span.font-semibold");
86+
if (queryRuntime) queryRuntimeText = queryRuntime.innerText;
87+
/** Generate a commit message *****************************/
88+
commitMsg = `[${probNum}] [Time Beats: ${queryRuntimeText}] - LeetPush`;
89+
await sessionStorage.setItem("commitMsg", commitMsg);
90+
} else {
91+
[runtime, memory] = document.querySelectorAll("div.flex.items-center.justify-between.gap-2 > div > div.rounded-sd.flex.min-w-\\[275px\\].flex-1.cursor-pointer.flex-col.px-4.py-3.text-xs > div:nth-child(3) > span.font-semibold");
92+
if (runtime && memory) {
93+
runtimeText = runtime.innerText;
94+
memoryText = memory.innerText;
95+
}
96+
/** Generate a commit message *****************************/
97+
commitMsg = `[${probNum}] [Time Beats: ${runtimeText}] [Memory Beats: ${memoryText}] - LeetPush`;
98+
await sessionStorage.setItem("commitMsg", commitMsg);
7699
}
77-
/** Generate a commit message *****************************/
78-
commitMsg = `[${probNum}] [Time Beats: ${runtimeText}] [Memory Beats: ${memoryText}] - LeetPush`;
79-
await sessionStorage.setItem("commitMsg", commitMsg);
80100
}
81101

82102
/** Select Buttons containter *******************************/

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "LeetPush",
4-
"version": "1.1.7",
4+
"version": "1.2.7",
55
"description": "Effortlessly capture and push LeetCode solutions to your GitHub repository",
66
"background": {
77
"service_worker": "background.js"

0 commit comments

Comments
 (0)