Skip to content

Commit 240f93c

Browse files
author
lucifer
committed
feat: 发布
1 parent 9d339fd commit 240f93c

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

‎leetcode-cheat.zip

317 KB
Binary file not shown.

‎public/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "leetcode cheatsheet",
44
"description": "刷题小助手,made by 力扣加加",
5-
"version": "0.2.2",
5+
"version": "0.3.0",
66
"browser_action": {
77
"default_popup": "index.html",
88
"default_title": "力扣加加"
@@ -16,6 +16,6 @@
1616
"js": ["/static/js/content.js"]
1717
}
1818
],
19-
"permissions": ["tabs", "activeTab"],
19+
"permissions": ["tabs"],
2020
"content_security_policy": "script-src 'self' 'sha256-9HcBuUP35aPkU0991A4mASdsuifTkUlifJ7elThz6Ow=' 'sha256-0Jo/EYaXS11i7poc/P9fGcq/o6P0djny2JW6WivTVVw='; object-src 'self'"
2121
}

‎src/contentScript.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { message } from "antd";
22
// import "./content.css";
3-
import { copyToClipboard } from "./utils";
3+
import { copyToClipboard, 不讲武德 } from "./utils";
44

55
// testcase eg: `bottom = "BCD", allowed = ["BCG", "CDE", "GEA", "FFF"], c = [1,2,3], d = 2`
66
function normalize(testCase) {
@@ -68,13 +68,14 @@ function getProviedTestCases() {
6868
for (let prefix of possiblePrefixs) {
6969
for (var i = 0; i < pres.length; ++i) {
7070
if (pres[i].innerText.includes(prefix)) {
71-
console.log(
72-
pres[i].innerText.match(new RegExp(`${prefix}(.*)输出`, "s"))
73-
);
7471
const testcase = pres[i].innerText.match(
75-
new RegExp(`${prefix}(.*?)输出`, "mgs")
76-
)[1];
77-
ans.push(normalize(testcase));
72+
new RegExp(`${prefix}(.*)输出`, "s")
73+
);
74+
console.log(testcase);
75+
if (testcase.length <= 1) {
76+
return 不讲武德();
77+
}
78+
ans.push(normalize(testcase[1]));
7879
}
7980
}
8081
if (ans.length > 0) return ans;
@@ -92,11 +93,7 @@ function insertButton() {
9293
copyButton.style["margin-left"] = "10px";
9394
copyButton.onclick = () => {
9495
const cases = getProviedTestCases();
95-
if (cases.filter(Boolean).length === 0)
96-
return message.error({
97-
content:
98-
"力扣不讲武德,不套路出牌。不过没关系啊,你反馈给我,我下次一定全部防出去啊!",
99-
});
96+
if (cases.filter(Boolean).length === 0) return 不讲武德();
10097
copyToClipboard(cases.join("\n"));
10198
message.success({
10299
content: "复制成功~",

‎src/utils.js

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import React from "react";
2+
import { Button, message } from "antd";
3+
import { ISSUES_URL } from "./constant/index";
4+
15
function TreeNode(value) {
26
return {
37
left: null,
@@ -92,6 +96,20 @@ export function buildRandomTree({
9296
return dfs({ upper, lower });
9397
}
9498

99+
export function 不讲武德() {
100+
return message.error({
101+
content: (
102+
<>
103+
力扣不讲武德,不套路出牌。不过没关系啊,你
104+
<Button type="link" href={ISSUES_URL} target="_blank">
105+
反馈
106+
</Button>
107+
给我,下次一定全部防出去!
108+
</>
109+
),
110+
});
111+
}
112+
95113
export function deserialise_bfs(nodes) {
96114
if (nodes.length === 0 || nodes[0] === "null") return null;
97115
const root = TreeNode(nodes[0]);

0 commit comments

Comments
 (0)