mirror of
https://github.com/lebr0nli/slader-extension.git
synced 2025-05-10 19:02:07 +00:00
handle hasInvalidKatex
This commit is contained in:
parent
38b6b93388
commit
c258ad0777
|
@ -70,7 +70,7 @@ function processData(data){
|
|||
if (column.text)
|
||||
{
|
||||
var textDiv = document.createElement('div');
|
||||
textDiv.classList.add('sladerBypassKatexTextArea')
|
||||
textDiv.classList.add('sladerBypassKatexTextArea');
|
||||
textDiv.textContent = column.text.replaceAll('\n\n\n', '\n\n'); // The replace call is a bit funky but it works.
|
||||
columnDiv.appendChild(textDiv);
|
||||
}
|
||||
|
@ -81,13 +81,16 @@ function processData(data){
|
|||
image.setAttribute('src', column.images.additional.regular.srcUrl);
|
||||
columnDiv.appendChild(image);
|
||||
}
|
||||
|
||||
// Append server-rendered image src url. Used in errorhandling. (See: handleKatexError())
|
||||
if (column.images.latex && column.images.latex.large)
|
||||
{
|
||||
div.querySelector('.sladerBypassKatex').setAttribute('katexsrc', column.images.latex.large.srcUrl);
|
||||
}
|
||||
|
||||
// handle hasInvalidKatex
|
||||
if(column.hasInvalidKatex)
|
||||
div.querySelector('.sladerBypassKatex').setAttribute('InvalidKatex', "true");
|
||||
|
||||
div.querySelector('.sladerBypassKatex').appendChild(columnDiv);
|
||||
});
|
||||
|
||||
|
@ -99,6 +102,7 @@ function processData(data){
|
|||
// Render Katex for each card
|
||||
expArea.querySelectorAll('.sladerBypassKatex').forEach(textArea => {
|
||||
try {
|
||||
if(!textArea.hasAttribute("InvalidKatex")){
|
||||
renderMathInElement(textArea, {
|
||||
delimiters: [
|
||||
{left: "$$", right: "$$", display: true},
|
||||
|
@ -114,6 +118,11 @@ function processData(data){
|
|||
throwOnError : true,
|
||||
errorCallback : function(a, b){ handleKatexError(a, b, textArea); }
|
||||
});
|
||||
}
|
||||
else{
|
||||
// sometimes even hasInvalidKatex, textArea still can render without error
|
||||
handleKatexError("hasInvalidKatex","hasInvalidKatex", textArea);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Katex experienced an error. Attempting to load image replacement.');
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "slader bypass",
|
||||
"version": "0.7",
|
||||
"version": "0.8",
|
||||
"author":"Alan Li & Ethan Harvey",
|
||||
"description": "Slader/Quizlet 5 solutions limit bypass",
|
||||
"permissions": [
|
||||
|
|
Loading…
Reference in a new issue