Attempt redirect

This commit is contained in:
EthanHarv 2021-07-13 06:18:56 -05:00
parent 89b503ed68
commit 4e4f94ffae
2 changed files with 15 additions and 15358 deletions

File diff suppressed because it is too large Load diff

View file

@ -34,8 +34,8 @@ function renderBypass()
{ {
if (window.location.toString().includes('quizlet.com/explanations/textbook-solutions')) if (window.location.toString().includes('quizlet.com/explanations/textbook-solutions'))
{ {
// TODO: Redirect to old site var oldlink = getOldTextbookLink();
expArea.innerHTML = `<div style="color: red;"><h1>Textbooks currently only supported by Slader Bypass on the old website.</h1><br>Click <a href="#">here</a> to be redirected to the working version of this question.</div>`; expArea.innerHTML = `<div style="color: red;"><h1>Textbooks currently only supported by Slader Bypass on the old website.</h1><br>Click <a href="` + oldlink + `">here</a> to be redirected to the working version of this question. If that doesn't work, try finding it manually on the old site.</div>`;
} }
else else
{ {
@ -44,7 +44,7 @@ function renderBypass()
} }
} }
// TODO: Branch off to handle textbookExercisePageData. See line 1349 in "deleteme.html". // TODO: Handle textbookExercisePageData.
// Parse JSON data // Parse JSON data
@ -113,3 +113,15 @@ function httpGet(url)
req.send( null ); req.send( null );
return req.responseText; return req.responseText;
} }
function getOldTextbookLink(url)
{
// This is mostly approximate.
const bookTitle = window.location.toString().match(/(?<=quizlet\.com\/explanations\/textbook-solutions\/).+?(?=-\d\d\d\d\d\d\d)/)[0];
const bookISBN = window.location.toString().split(bookTitle)[1].split('/')[0].replaceAll('-', '');
const page = document.getElementsByClassName('tsqwngb')[0].children[1].innerHTML.slice(5);
const problem = document.getElementsByClassName('t1aekklg')[0].innerHTML.slice(9);
return "https://www.slader.com/textbook/" + bookISBN + '-' + bookTitle + '/' + page + '/problems/' + problem;
}