Skip to content

Commit 028be9e

Browse files
author
robot
committed
feat: 更新题目
1 parent efb5ed9 commit 028be9e

File tree

6 files changed

+2228
-8481
lines changed

6 files changed

+2228
-8481
lines changed

leetcode-cheat.zip

-168 KB
Binary file not shown.

public/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "leetcode cheatsheet",
44
"description": "刷题小助手,made by 力扣加加",
5-
"version": "0.12.0",
5+
"version": "0.12.1",
66
"action": {
77
"default_popup": "index.html",
88
"default_title": "力扣加加"

src/contentScript.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function insertButton() {
372372

373373
for (var i = 0; i < buttons.length; ++i) {
374374
if (buttons[i].innerText.includes(t("Locale.app.run"))) {
375-
375+
376376
// const container = document.createElement("div");
377377

378378
// buttons[i].parentElement.prepend(container);
@@ -404,17 +404,19 @@ function insertButton() {
404404
writeSolutionButton.className = buttons[i].className;
405405

406406
writeSolutionButton.onclick = () => {
407+
console.log("writeSolutionButton");
407408
// d: "<a href="/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/">1579. 保证图可完全遍历</a>"
408409

409410
const desc = document.querySelector(
410-
"[data-track-load=\"description_content\"]"
411+
'[data-track-load="description_content"]'
411412
).innerHTML;
412413

413414
if (!desc) {
414415
return message.warn({
415416
content: t("app.getProblemError"),
416417
});
417418
}
419+
418420
const title = document.title;
419421
const link = window.location.href;
420422
const language = getCodeLanguage();
@@ -426,6 +428,8 @@ function insertButton() {
426428
// const desc = document.querySelector("#question-detail-main-tabs")?.children[1]?.children[0]?.children[1]?.innerText;
427429

428430
const hide = message.loading(t("app.savingProblem"), 0);
431+
432+
console.log("writeSolutionButton", title, link, language, code, desc);
429433
writeSolutionButton.setAttribute("disabled", true);
430434
// Dismiss manually and asynchronously
431435
setTimeout(() => {
@@ -442,7 +446,8 @@ function insertButton() {
442446
raw: "e574bf60b50d8d2d2db2320ee83aba3cd29cecf2",
443447
}))
444448
.then((res) => {
445-
const t = res.raw;
449+
const token = res.raw;
450+
console.log("getStorage", token);
446451
setCloundStorage(
447452
{
448453
title,
@@ -453,10 +458,11 @@ function insertButton() {
453458
},
454459

455460
{
456-
token: t,
461+
token: token,
457462
}
458463
)
459464
.then((res) => {
465+
console.log("setCloundStorage", res);
460466
hide();
461467
writeSolutionButton.removeAttribute("disabled");
462468
if (res.id) {
@@ -468,15 +474,24 @@ function insertButton() {
468474
content: t("app.githubAPIError"),
469475
});
470476
setTimeout(() => {
471-
window.open(
472-
`https://leetcode-pp.github.io/leetcode-cheat/?title=${title}&link=${link}&language=${language}&tab=solution-template`
473-
);
474-
}, 2000);
477+
const url = `https://leetcode-pp.github.io/leetcode-cheat/?title=${title}&link=${link}&language=${language}&tab=solution-template`;
478+
console.log("window.open", url);
479+
window.open(url);
480+
}, 1000);
475481
}
476482
})
477483
.catch(() => {
484+
console.log("setCloundStorage", "catch");
478485
hide();
479486
writeSolutionButton.removeAttribute("disabled");
487+
message.warn({
488+
content: t("app.githubAPIError"),
489+
});
490+
setTimeout(() => {
491+
window.open(
492+
`https://leetcode-pp.github.io/leetcode-cheat/?title=${title}&link=${link}&language=${language}&tab=solution-template`
493+
);
494+
}, 1000);
480495
});
481496
});
482497
};
@@ -501,7 +516,7 @@ function insertButton() {
501516
inserted = true;
502517
} else if (buttons[i].innerText.includes(t("app.submit"))) {
503518
const click = buttons[i].onclick;
504-
const originalFn = buttons[i]
519+
const originalFn = buttons[i];
505520
buttons[i].onclick = (...args) => {
506521
click.call(originalFn, ...args);
507522

@@ -543,8 +558,8 @@ const timerId = setInterval(() => {
543558
}
544559

545560
// 防止 insertButton 在本插件应用中执行,会匹配到题目中包含 "Run" 的情况,例如:“1480. Running Sum of 1d Array”
546-
if (document.title.includes("力扣加加")) return
547-
561+
if (document.title.includes("力扣加加")) return;
562+
548563
insertButton();
549564

550565
// if (inserted && submitProxied) {

0 commit comments

Comments
 (0)