// ==UserScript==
// @name Poe Latex Renderer
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Prelimary Version, handwork needed
// @author You
// @match https://poe.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=poe.com
// @grant none
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
function createBtn() {
const _sc_renderBtnContainer = document.createElement("div");
_sc_renderBtnContainer.style.cssText = `
display: flex;
align-items: center;
justify-content: center;
height: 50px;
`
_sc_renderBtnContainer.innerHTML = '';
_sc_renderBtnContainer.addEventListener('click', () => { MathJax.typeset(); })
const _sc_writeBtnContainer = document.createElement("div");
_sc_writeBtnContainer.style.cssText = `
display: flex;
align-items: center;
justify-content: center;
height: 50px;
`
_sc_writeBtnContainer.innerHTML = ''
_sc_writeBtnContainer.addEventListener('click', ()=>{
document.querySelector("[class*='ChatMessageInputView_textInput__Aervw']").value += "\n\n Please write your equations in Latex, surrounded by $$.";
document.querySelector("[class*='ChatMessageInputView_sendButton_']").click();
})
document.querySelector("[class*='ChatMessageInputView_inputWrapper']").prepend(_sc_writeBtnContainer)
document.querySelector("[class*='ChatMessageInputView_inputWrapper']").prepend(_sc_renderBtnContainer)
}
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath : [['$$', '$$', ['\\[', '\\]']]]
},
svg: {
fontCache: 'global'
},
options: {
skipHtmlTags: [ // HTML tags that won't be searched for math
'script', 'noscript', 'style', 'textarea', 'annotation', 'annotation-xml'],
includeHtmlTags: { // HTML tags that can appear within math
br: '\n',
wbr: '',
'#comment': ''
},
ignoreHtmlClass: 'tex2jax_ignore',
// class that marks tags not to search
processHtmlClass: 'tex2jax_process',
// class that marks tags that should be searched
compileError: function(doc, math, err) {
doc.compileError(math, err)
},
typesetError: function(doc, math, err) {
doc.typesetError(math, err)
},
}
};
(function () {
var script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js';
script.async = true;
document.head.appendChild(script);
})();
setTimeout(createBtn, 2000);
// Your code here...
})();