Skip to content

Commit c076712

Browse files
committed
Add page
1 parent aa6a66f commit c076712

14 files changed

+392
-134
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ keys.json
3737

3838
# typescript
3939
.tsbuildinfo
40+
41+
.idea/

assets/icon.png

50.1 KB
Loading

assets/icon.svg

Lines changed: 0 additions & 21 deletions
This file was deleted.

locales/zh/messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"popup": {
3-
"message": "Leecode Editor Extension适用于leecode.comleetcode.cn或codetop.cc请确保你在页面上.",
3+
"message": "Leecode Editor Extension适用于leecode.com,leetcode.cn或codetop.cc. 请确保你在页面上.",
44
"description": "Popup message."
55
},
66
"options_desc": {

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "leetcode-editor-extension",
33
"displayName": "Leetcode editor extension",
4-
"version": "0.0.1",
5-
"description": "A basic Plasmo extension.",
4+
"version": "0.0.2",
5+
"description": "Quickly open problems in IntelliJ Platform IDEs.",
66
"author": "shuzijun",
77
"scripts": {
88
"dev": "plasmo dev",
99
"build": "plasmo build"
1010
},
1111
"dependencies": {
12+
"@ant-design/icons": "^4.7.0",
1213
"@jetbrains/logos": "^2.2.7",
1314
"@plasmohq/storage": "^0.12.2",
1415
"antd": "^4.23.5",
@@ -22,7 +23,7 @@
2223
"@types/node": "18.8.3",
2324
"@types/react": "18.0.21",
2425
"@types/react-dom": "18.0.6",
25-
"plasmo": "0.56.1",
26+
"plasmo": "0.57.1",
2627
"prettier": "2.7.1",
2728
"typescript": "4.8.4"
2829
},

pnpm-lock.yaml

Lines changed: 42 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/contents/codetop-cc-list.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import type {PlasmoContentScript} from "plasmo"
2+
import {useStorage} from "@plasmohq/storage/hook"
3+
import React from "react"
4+
import {createRoot} from "react-dom/client"
5+
6+
import {Button} from 'antd';
7+
import {GetLogoSize} from "~logo"
8+
9+
export const config: PlasmoContentScript = {
10+
matches: ["https://codetop.cc/home*"]
11+
}
12+
13+
export const getRootContainer = () =>
14+
new Promise((resolve) => {
15+
const checkInterval = setInterval(() => {
16+
const rootContainer = document.querySelector(".el-table__body-wrapper > .el-table__body > tbody")
17+
if (rootContainer) {
18+
clearInterval(checkInterval)
19+
resolve(rootContainer)
20+
}
21+
}, 137)
22+
})
23+
24+
const CodeTopCCList = ({sulg}) => {
25+
26+
const [showIcon] = useStorage("ShowIcon", true)
27+
const logo = GetLogoSize(14)
28+
const url = GetUrl() + sulg
29+
30+
return (<Button hidden={!showIcon} type="text" href={url} icon={logo} target='_blank'/>)
31+
}
32+
33+
export const render = async ({createRootContainer}) => {
34+
35+
const rootContainer = await createRootContainer()
36+
37+
const els = rootContainer.querySelectorAll("tr > td:nth-child(1) > div")
38+
for (let i = 0; i < els.length; i++) {
39+
const d = document.createElement("div")
40+
d.style = "display: inline;padding-right:10px"
41+
els[i].insertBefore(d, els[i].lastChild)
42+
const root = createRoot(d)
43+
let sulg = els[i].getElementsByTagName("a")[0].getAttribute("href").split('/')[4]
44+
root.render(<CodeTopCCList sulg={sulg}/>);
45+
}
46+
}
47+
48+
49+
const GetUrl = () => {
50+
const [editor] = useStorage("Editor", "leetcode-editor-pro")
51+
const [product] = useStorage("Product", "idea")
52+
const [project] = useStorage("Project", "")
53+
54+
return "jetbrains://" + product + "/" + editor + "/open?project=" + project + "&slug="
55+
}
56+
57+
export default CodeTopCCList

0 commit comments

Comments
 (0)