|
5 | 5 | // import { Menu, Dropdown, Button } from "antd";
|
6 | 6 | // import { DownOutlined, UserOutlined } from "@ant-design/icons";
|
7 | 7 | import {
|
8 |
| - copyToClipboard, |
9 |
| - bjwd, |
| 8 | + // bjwd, |
10 | 9 | getStorage,
|
11 | 10 | setCloundStorage,
|
12 | 11 | // addStyle,
|
13 | 12 | } from "./utils";
|
14 |
| -import zenAble from "./zen/zenMode"; |
| 13 | +// import zenAble from "./zen/zenMode"; |
15 | 14 | import hideFailCases from "./submission/hideFailCases";
|
16 | 15 |
|
17 | 16 | // WTF! ant message didn't go well with chrome extension?
|
@@ -84,115 +83,115 @@ const message = {
|
84 | 83 | // } else
|
85 | 84 |
|
86 | 85 | // testcase eg: `bottom = "BCD", allowed = ["BCG", "CDE", "GEA", "FFF"], c = [1,2,3], d = 2`
|
87 |
| -function normalize(testCase, includeArray = true) { |
88 |
| - testCase = testCase.trim().replace(/\n/g, "").replace(" ", ""); |
89 |
| - |
90 |
| - // 单一参数 |
91 |
| - // console.log(testCase); |
92 |
| - if (!testCase.includes("=")) { |
93 |
| - // 数组直接返回 |
94 |
| - // eslint-disable-next-line |
95 |
| - if (testCase.includes("[") || testCase.includes('"')) { |
96 |
| - return testCase; |
97 |
| - } else { |
98 |
| - // 输入: 3, 2, 0, 0 |
99 |
| - // 输入: 0.0625 |
100 |
| - |
101 |
| - const parts = testCase.split(","); |
102 |
| - if (parts.length === 0) return parts.join(""); |
103 |
| - return parts.join("\n"); |
104 |
| - } |
105 |
| - } |
106 |
| - let stack = []; |
107 |
| - let i = 0; |
108 |
| - while (i < testCase.length) { |
109 |
| - while (i < testCase.length && testCase[i] !== "=") { |
110 |
| - i += 1; |
111 |
| - } |
112 |
| - // skip = |
113 |
| - i += 1; |
114 |
| - |
115 |
| - while (i < testCase.length && testCase[i] !== "[" && testCase[i] !== ",") { |
116 |
| - stack.push(testCase[i]); |
117 |
| - i += 1; |
118 |
| - } |
119 |
| - if (testCase[i] === ",") { |
120 |
| - // skip , |
121 |
| - i += 1; |
122 |
| - stack.push("\n"); |
123 |
| - } else if (includeArray) { |
124 |
| - // 解析为数组 |
125 |
| - // cnt 左括号[ 与 右括号] 个数的差值 |
126 |
| - let cnt = 0; |
127 |
| - while (i < testCase.length) { |
128 |
| - stack.push(testCase[i]); |
129 |
| - cnt += testCase[i] === "["; |
130 |
| - cnt -= testCase[i] === "]"; |
131 |
| - i += 1; |
132 |
| - if (cnt === 0) { |
133 |
| - if (i !== testCase.length) { |
134 |
| - stack.push("\n"); |
135 |
| - } |
| 86 | +// function normalize(testCase, includeArray = true) { |
| 87 | +// testCase = testCase.trim().replace(/\n/g, "").replace(" ", ""); |
| 88 | + |
| 89 | +// // 单一参数 |
| 90 | +// // console.log(testCase); |
| 91 | +// if (!testCase.includes("=")) { |
| 92 | +// // 数组直接返回 |
| 93 | +// // eslint-disable-next-line |
| 94 | +// if (testCase.includes("[") || testCase.includes('"')) { |
| 95 | +// return testCase; |
| 96 | +// } else { |
| 97 | +// // 输入: 3, 2, 0, 0 |
| 98 | +// // 输入: 0.0625 |
| 99 | + |
| 100 | +// const parts = testCase.split(","); |
| 101 | +// if (parts.length === 0) return parts.join(""); |
| 102 | +// return parts.join("\n"); |
| 103 | +// } |
| 104 | +// } |
| 105 | +// let stack = []; |
| 106 | +// let i = 0; |
| 107 | +// while (i < testCase.length) { |
| 108 | +// while (i < testCase.length && testCase[i] !== "=") { |
| 109 | +// i += 1; |
| 110 | +// } |
| 111 | +// // skip = |
| 112 | +// i += 1; |
| 113 | + |
| 114 | +// while (i < testCase.length && testCase[i] !== "[" && testCase[i] !== ",") { |
| 115 | +// stack.push(testCase[i]); |
| 116 | +// i += 1; |
| 117 | +// } |
| 118 | +// if (testCase[i] === ",") { |
| 119 | +// // skip , |
| 120 | +// i += 1; |
| 121 | +// stack.push("\n"); |
| 122 | +// } else if (includeArray) { |
| 123 | +// // 解析为数组 |
| 124 | +// // cnt 左括号[ 与 右括号] 个数的差值 |
| 125 | +// let cnt = 0; |
| 126 | +// while (i < testCase.length) { |
| 127 | +// stack.push(testCase[i]); |
| 128 | +// cnt += testCase[i] === "["; |
| 129 | +// cnt -= testCase[i] === "]"; |
| 130 | +// i += 1; |
| 131 | +// if (cnt === 0) { |
| 132 | +// if (i !== testCase.length) { |
| 133 | +// stack.push("\n"); |
| 134 | +// } |
136 | 135 |
|
137 |
| - break; |
138 |
| - } |
139 |
| - } |
140 |
| - } else { |
141 |
| - while (i < testCase.length) { |
142 |
| - stack.push(testCase[i]); |
143 |
| - i += 1; |
144 |
| - } |
145 |
| - } |
146 |
| - } |
147 |
| - const ans = stack.join(""); |
148 |
| - if (includeArray && ans[ans.length - 1] !== testCase[testCase.length - 1]) { |
149 |
| - return normalize(testCase, false); |
150 |
| - } |
151 |
| - return stack.join(""); |
152 |
| -} |
| 136 | +// break; |
| 137 | +// } |
| 138 | +// } |
| 139 | +// } else { |
| 140 | +// while (i < testCase.length) { |
| 141 | +// stack.push(testCase[i]); |
| 142 | +// i += 1; |
| 143 | +// } |
| 144 | +// } |
| 145 | +// } |
| 146 | +// const ans = stack.join(""); |
| 147 | +// if (includeArray && ans[ans.length - 1] !== testCase[testCase.length - 1]) { |
| 148 | +// return normalize(testCase, false); |
| 149 | +// } |
| 150 | +// return stack.join(""); |
| 151 | +// } |
153 | 152 |
|
154 |
| -function extractTestCase(text, prefix) { |
155 |
| - const possiblePrefixs = [ |
156 |
| - "输出", |
157 |
| - "返回", |
158 |
| - "Output", |
159 |
| - "output", |
160 |
| - "Return", |
161 |
| - "return", |
162 |
| - "", |
163 |
| - ]; |
164 |
| - for (let tag of possiblePrefixs) { |
165 |
| - const testCase = text.match(new RegExp(`${prefix}(.*)${tag}`, "s")); |
166 |
| - if (testCase && testCase.length > 1) { |
167 |
| - return testCase; |
168 |
| - } |
169 |
| - } |
170 |
| - return []; |
171 |
| -} |
| 153 | +// function extractTestCase(text, prefix) { |
| 154 | +// const possiblePrefixs = [ |
| 155 | +// "输出", |
| 156 | +// "返回", |
| 157 | +// "Output", |
| 158 | +// "output", |
| 159 | +// "Return", |
| 160 | +// "return", |
| 161 | +// "", |
| 162 | +// ]; |
| 163 | +// for (let tag of possiblePrefixs) { |
| 164 | +// const testCase = text.match(new RegExp(`${prefix}(.*)${tag}`, "s")); |
| 165 | +// if (testCase && testCase.length > 1) { |
| 166 | +// return testCase; |
| 167 | +// } |
| 168 | +// } |
| 169 | +// return []; |
| 170 | +// } |
172 | 171 |
|
173 |
| -function getProviedTestCases(includeArray = true) { |
174 |
| - const possibleTags = ["pre", "p"]; |
175 |
| - const possiblePrefixs = ["输入:", "输入:", "Input:", "input:"]; |
176 |
| - const ans = []; |
177 |
| - for (let tag of possibleTags) { |
178 |
| - const pres = document.querySelectorAll(tag); |
179 |
| - |
180 |
| - for (let prefix of possiblePrefixs) { |
181 |
| - for (var i = 0; i < pres.length; ++i) { |
182 |
| - if (pres[i].innerText.includes(prefix)) { |
183 |
| - const testcase = extractTestCase(pres[i].innerText, prefix); |
184 |
| - if (!testcase || testcase.length <= 1) { |
185 |
| - bjwd(); |
186 |
| - return []; |
187 |
| - } |
188 |
| - ans.push(normalize(testcase[1], includeArray)); |
189 |
| - } |
190 |
| - } |
191 |
| - if (ans.length > 0) return ans; |
192 |
| - } |
193 |
| - } |
194 |
| - return ans; |
195 |
| -} |
| 172 | +// function getProviedTestCases(includeArray = true) { |
| 173 | +// const possibleTags = ["pre", "p"]; |
| 174 | +// const possiblePrefixs = ["输入:", "输入:", "Input:", "input:"]; |
| 175 | +// const ans = []; |
| 176 | +// for (let tag of possibleTags) { |
| 177 | +// const pres = document.querySelectorAll(tag); |
| 178 | + |
| 179 | +// for (let prefix of possiblePrefixs) { |
| 180 | +// for (var i = 0; i < pres.length; ++i) { |
| 181 | +// if (pres[i].innerText.includes(prefix)) { |
| 182 | +// const testcase = extractTestCase(pres[i].innerText, prefix); |
| 183 | +// if (!testcase || testcase.length <= 1) { |
| 184 | +// bjwd(); |
| 185 | +// return []; |
| 186 | +// } |
| 187 | +// ans.push(normalize(testcase[1], includeArray)); |
| 188 | +// } |
| 189 | +// } |
| 190 | +// if (ans.length > 0) return ans; |
| 191 | +// } |
| 192 | +// } |
| 193 | +// return ans; |
| 194 | +// } |
196 | 195 | // const menu = (
|
197 | 196 | // <Menu onClick={() => handleTestCaseClick(false)}>
|
198 | 197 | // <Menu.Item key="1" icon={<UserOutlined />}>
|
@@ -499,8 +498,9 @@ function insertButton() {
|
499 | 498 | inserted = true;
|
500 | 499 | } else if (buttons[i].innerText.includes("提交")) {
|
501 | 500 | const click = buttons[i].onclick;
|
| 501 | + const originalFn = buttons[i] |
502 | 502 | buttons[i].onclick = (...args) => {
|
503 |
| - click.call(buttons[i], ...args); |
| 503 | + click.call(originalFn, ...args); |
504 | 504 |
|
505 | 505 | // try to hide failed test cases
|
506 | 506 | let tries = 0;
|
|
0 commit comments