-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession Submit Button.user.js
53 lines (43 loc) · 1.72 KB
/
Session Submit Button.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ==UserScript==
// @name Session Submit Button
// @namespace https://nawanae.github.io/Leetcode-Session-Browser-Binding/
// @version 1.1
// @namespace https://nawanae.github.io/Leetcode-Session-Browser-Binding/Session Submit Button.user.js
// @updateURL https://nawanae.github.io/Leetcode-Session-Browser-Binding/Session Submit Button.user.js
// @description Force Submit Code by Browser Session
// @author NawaNawa
// @match https://leetcode.com/problems/*/
// @icon https://www.google.com/s2/favicons?domain=leetcode.com
// @require https://nawanae.github.io/Leetcode-Session-Browser-Binding/src/leetCodeApi.js
// @grant none
// ==/UserScript==
(async function() {
'use strict';
console.log(API);
var callback = async function()
{
var orisubmitBtn = document.querySelector("button[data-cy='submit-code-btn']");
console.log(orisubmitBtn)
let sessionStorage = localStorage.getItem("session");
if(!orisubmitBtn || !sessionStorage || sessionStorage == 'undefined')return ;
var btnContainer = orisubmitBtn.parentNode;
var submitBtn = orisubmitBtn.cloneNode(true);
submitBtn=submitBtn.cloneNode(true);
submitBtn.innerText = `by ${sessionStorage}`;
submitBtn.onclick = async function(e)
{
await API.changeSessionByName(sessionStorage);
orisubmitBtn.click();
};
btnContainer.append(submitBtn);
}
var tid = setInterval(()=>{
var orisubmitBtn = document.querySelector("button[data-cy='submit-code-btn']");
if(orisubmitBtn)
{
clearInterval(tid);
callback();
}
},200);
// Your code here...
})();