@@ -372,7 +372,7 @@ function insertButton() {
372
372
373
373
for ( var i = 0 ; i < buttons . length ; ++ i ) {
374
374
if ( buttons [ i ] . innerText . includes ( t ( "Locale.app.run" ) ) ) {
375
-
375
+
376
376
// const container = document.createElement("div");
377
377
378
378
// buttons[i].parentElement.prepend(container);
@@ -404,17 +404,19 @@ function insertButton() {
404
404
writeSolutionButton . className = buttons [ i ] . className ;
405
405
406
406
writeSolutionButton . onclick = ( ) => {
407
+ console . log ( "writeSolutionButton" ) ;
407
408
// d: "<a href="/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/">1579. 保证图可完全遍历</a>"
408
409
409
410
const desc = document . querySelector (
410
- " [data-track-load=\ "description_content\"]"
411
+ ' [data-track-load="description_content"]'
411
412
) . innerHTML ;
412
413
413
414
if ( ! desc ) {
414
415
return message . warn ( {
415
416
content : t ( "app.getProblemError" ) ,
416
417
} ) ;
417
418
}
419
+
418
420
const title = document . title ;
419
421
const link = window . location . href ;
420
422
const language = getCodeLanguage ( ) ;
@@ -426,6 +428,8 @@ function insertButton() {
426
428
// const desc = document.querySelector("#question-detail-main-tabs")?.children[1]?.children[0]?.children[1]?.innerText;
427
429
428
430
const hide = message . loading ( t ( "app.savingProblem" ) , 0 ) ;
431
+
432
+ console . log ( "writeSolutionButton" , title , link , language , code , desc ) ;
429
433
writeSolutionButton . setAttribute ( "disabled" , true ) ;
430
434
// Dismiss manually and asynchronously
431
435
setTimeout ( ( ) => {
@@ -442,7 +446,8 @@ function insertButton() {
442
446
raw : "e574bf60b50d8d2d2db2320ee83aba3cd29cecf2" ,
443
447
} ) )
444
448
. then ( ( res ) => {
445
- const t = res . raw ;
449
+ const token = res . raw ;
450
+ console . log ( "getStorage" , token ) ;
446
451
setCloundStorage (
447
452
{
448
453
title,
@@ -453,10 +458,11 @@ function insertButton() {
453
458
} ,
454
459
455
460
{
456
- token : t ,
461
+ token : token ,
457
462
}
458
463
)
459
464
. then ( ( res ) => {
465
+ console . log ( "setCloundStorage" , res ) ;
460
466
hide ( ) ;
461
467
writeSolutionButton . removeAttribute ( "disabled" ) ;
462
468
if ( res . id ) {
@@ -468,15 +474,24 @@ function insertButton() {
468
474
content : t ( "app.githubAPIError" ) ,
469
475
} ) ;
470
476
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 ) ;
475
481
}
476
482
} )
477
483
. catch ( ( ) => {
484
+ console . log ( "setCloundStorage" , "catch" ) ;
478
485
hide ( ) ;
479
486
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 ) ;
480
495
} ) ;
481
496
} ) ;
482
497
} ;
@@ -501,7 +516,7 @@ function insertButton() {
501
516
inserted = true ;
502
517
} else if ( buttons [ i ] . innerText . includes ( t ( "app.submit" ) ) ) {
503
518
const click = buttons [ i ] . onclick ;
504
- const originalFn = buttons [ i ]
519
+ const originalFn = buttons [ i ] ;
505
520
buttons [ i ] . onclick = ( ...args ) => {
506
521
click . call ( originalFn , ...args ) ;
507
522
@@ -543,8 +558,8 @@ const timerId = setInterval(() => {
543
558
}
544
559
545
560
// 防止 insertButton 在本插件应用中执行,会匹配到题目中包含 "Run" 的情况,例如:“1480. Running Sum of 1d Array”
546
- if ( document . title . includes ( "力扣加加" ) ) return
547
-
561
+ if ( document . title . includes ( "力扣加加" ) ) return ;
562
+
548
563
insertButton ( ) ;
549
564
550
565
// if (inserted && submitProxied) {
0 commit comments