From 2e69192e6b3c37b74cbf4aa1dce9cd60821ff63c Mon Sep 17 00:00:00 2001 From: Brandon Fowler Date: Sat, 10 Feb 2024 17:12:55 -0500 Subject: [PATCH 1/3] Only try to show token renewal when a pending token is found Fixes #6 --- MarmoUI-Chrome/scripts/script.js | 9 +++++---- marmo-ui.user.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/MarmoUI-Chrome/scripts/script.js b/MarmoUI-Chrome/scripts/script.js index fae519a..8c2723b 100644 --- a/MarmoUI-Chrome/scripts/script.js +++ b/MarmoUI-Chrome/scripts/script.js @@ -645,14 +645,15 @@ function runMarmoUI() try { //Grab the token from the page - var tokens = requestResult.match(/You currently have \d+ release/)[0].match(/\d+/)[0]; + var tokens = requestResult.match(/You currently have (\d+) release/)[1]; var tokenText = tokens; + //Get list of pending tokens + var pendingTokens = requestResult.match(/\[a-zA-Z0-9 ,\:]+\/g); //Find the next release token availability - if(tokens < 3) + if(pendingTokens) { //First release token - var tokens = requestResult.match(/\[a-zA-Z0-9 ,\:]+\/g); - var tmp = tokens[tokens.length - 1]; + var tmp = pendingTokens[tokens.length - 1]; //Calculate time difference var nextToken = parseMarmosetDate(tmp) - Date.now(); //Add in the text for the next token time diff --git a/marmo-ui.user.js b/marmo-ui.user.js index a5adfe2..a9409f0 100644 --- a/marmo-ui.user.js +++ b/marmo-ui.user.js @@ -625,14 +625,15 @@ function runMarmoUI() try { //Grab the token from the page - var tokens = requestResult.match(/You currently have \d+ release/)[0].match(/\d+/)[0]; + var tokens = requestResult.match(/You currently have (\d+) release/)[1]; var tokenText = tokens; + //Get list of pending tokens + var pendingTokens = requestResult.match(/\[a-zA-Z0-9 ,\:]+\/g); //Find the next release token availability - if(tokens < 3) + if(pendingTokens) { //First release token - var tokens = requestResult.match(/\[a-zA-Z0-9 ,\:]+\/g); - var tmp = tokens[tokens.length - 1]; + var tmp = pendingTokens[tokens.length - 1]; //Calculate time difference var nextToken = parseMarmosetDate(tmp) - Date.now(); //Add in the text for the next token time From 1a0db1c74423d79669eb7c6139c52d5aa831a2a3 Mon Sep 17 00:00:00 2001 From: Brandon Fowler Date: Sat, 10 Feb 2024 17:13:37 -0500 Subject: [PATCH 2/3] Default to N/A tokens --- MarmoUI-Chrome/scripts/script.js | 4 ++-- marmo-ui.user.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MarmoUI-Chrome/scripts/script.js b/MarmoUI-Chrome/scripts/script.js index 8c2723b..5b6d070 100644 --- a/MarmoUI-Chrome/scripts/script.js +++ b/MarmoUI-Chrome/scripts/script.js @@ -664,8 +664,8 @@ function runMarmoUI() } catch(error) { - //Set to 3 tokens if we can't find the token string - tableCell.html("3"); + //Set to N/A if we can't find the token string + tableCell.html("N/A"); } } diff --git a/marmo-ui.user.js b/marmo-ui.user.js index a9409f0..294ba0d 100644 --- a/marmo-ui.user.js +++ b/marmo-ui.user.js @@ -644,8 +644,8 @@ function runMarmoUI() } catch(error) { - //Set to 3 tokens if we can't find the token string - tableCell.html("3"); + //Set to N/A if we can't find the token string + tableCell.html("N/A"); } } From 80787eb0236f3eeb071c42605ceb3db94d0ccac4 Mon Sep 17 00:00:00 2001 From: Brandon Fowler Date: Sat, 10 Feb 2024 17:17:50 -0500 Subject: [PATCH 3/3] Show renewal for token that is renewing the soonest --- MarmoUI-Chrome/scripts/script.js | 4 +--- marmo-ui.user.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/MarmoUI-Chrome/scripts/script.js b/MarmoUI-Chrome/scripts/script.js index 5b6d070..06f0a5d 100644 --- a/MarmoUI-Chrome/scripts/script.js +++ b/MarmoUI-Chrome/scripts/script.js @@ -652,10 +652,8 @@ function runMarmoUI() //Find the next release token availability if(pendingTokens) { - //First release token - var tmp = pendingTokens[tokens.length - 1]; //Calculate time difference - var nextToken = parseMarmosetDate(tmp) - Date.now(); + var nextToken = parseMarmosetDate(pendingTokens[0]) - Date.now(); //Add in the text for the next token time tokenText += " (renew in " + Math.floor(nextToken / 3600000) + "h " + Math.floor((nextToken % 3600000) / 60000) + "m)"; } diff --git a/marmo-ui.user.js b/marmo-ui.user.js index 294ba0d..2cb1b96 100644 --- a/marmo-ui.user.js +++ b/marmo-ui.user.js @@ -632,10 +632,8 @@ function runMarmoUI() //Find the next release token availability if(pendingTokens) { - //First release token - var tmp = pendingTokens[tokens.length - 1]; //Calculate time difference - var nextToken = parseMarmosetDate(tmp) - Date.now(); + var nextToken = parseMarmosetDate(pendingTokens[0]) - Date.now(); //Add in the text for the next token time tokenText += " (renew in " + Math.floor(nextToken / 3600000) + "h " + Math.floor((nextToken % 3600000) / 60000) + "m)"; }