Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyperlinked green-tick #222

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions scripts/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,11 @@ const loader = setInterval(() => {
const language = findLanguage();
if (language !== null) {
// start upload indicator here
startUpload();
chrome.storage.local.get('leethub_hook', (h) => {
const hook = h.leethub_hook;
const repoURL = `https://github.com/${hook}`;
startUpload(repoURL);
});
chrome.storage.local.get('stats', (s) => {
const { stats } = s;
const filePath = problemName + problemName + language;
Expand Down Expand Up @@ -740,7 +744,7 @@ function insertToAnchorElement(elem) {
}

/* start upload will inject a spinner on left side to the "Run Code" button */
function startUpload() {
function startUpload(url) {
try {
elem = document.getElementById('leethub_progress_anchor_element');
if (!elem) {
Expand All @@ -749,7 +753,11 @@ function startUpload() {
elem.style = 'margin-right: 20px;padding-top: 2px;';
}
elem.innerHTML = `<div id="leethub_progress_elem" class="leethub_progress"></div>`;
target = insertToAnchorElement(elem);
const hyperLinkWrapper = document.createElement('a');
hyperLinkWrapper.href = url;
hyperLinkWrapper.target = '_blank';
hyperLinkWrapper.appendChild(elem);
target = insertToAnchorElement(hyperLinkWrapper);
// start the countdown
startUploadCountDown();
} catch (error) {
Expand Down