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

Improve token display on course pages #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions MarmoUI-Chrome/scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,16 +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(/\<li\>[a-zA-Z0-9 ,\:]+\<br\>/g);
//Find the next release token availability
if(tokens < 3)
if(pendingTokens)
{
//First release token
var tokens = requestResult.match(/\<li\>[a-zA-Z0-9 ,\:]+\<br\>/g);
var tmp = tokens[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)";
}
Expand All @@ -663,8 +662,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");
}
}

Expand Down
15 changes: 7 additions & 8 deletions marmo-ui.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,16 +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(/\<li\>[a-zA-Z0-9 ,\:]+\<br\>/g);
//Find the next release token availability
if(tokens < 3)
if(pendingTokens)
{
//First release token
var tokens = requestResult.match(/\<li\>[a-zA-Z0-9 ,\:]+\<br\>/g);
var tmp = tokens[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)";
}
Expand All @@ -643,8 +642,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");
}
}

Expand Down