// Created by Samuel Lord (NodeMixaholic/Sparksammy) // Now Maintained by Sneed Group // Licensed under Samuel Public License with <3 class JSPlusPlus { General = class { //Eval alternative //Example: exec("alert('Hello, world!')") exec(jsCode) { let js = jsCode.toString(); Function(js)() } require(jsURI) { try { let req = JSPlusPlus.Frontend.readInternetText(jsURI); JSPlusPlus.General.exec(req); } catch { console.log(`Error! (Using Node.JS?) If on NodeJS or equivalent try: 'let ${jsURI} = require("${jsURI}")'`) } } } Frontend = class { // Get element by ID getElementById(elementID) { return document.getElementById(elementID) } //Convert markdown to HTML and back markdownToHTML(markdown) { // Replace headers (h1, h2, h3) with corresponding HTML tags markdown = markdown.replace(/^# (.*$)/gim, '

$1

'); markdown = markdown.replace(/^## (.*$)/gim, '

$1

'); markdown = markdown.replace(/^### (.*$)/gim, '

$1

'); // Replace bold and italic text with corresponding HTML tags markdown = markdown.replace(/\*\*(.*)\*\*/gim, '$1'); markdown = markdown.replace(/\*(.*)\*/gim, '$1'); // Replace unordered list items with HTML list tags markdown = markdown.replace(/\* (.*?)(\n|$)/gim, '
  • $1
  • '); // Replace inline code with HTML tag markdown = markdown.replace(/`(.*?)`/gim, '$1'); // Replace blockquotes with HTML
    tag markdown = markdown.replace(/^\s*> (.*)$/gim, '
    $1
    '); // Replace horizontal rules with HTML
    tag markdown = markdown.replace(/^\s*[-*_]{3,}\s*$/gim, '
    '); // Replace line breaks with HTML
    tag markdown = markdown.replace(/\n$/gim, '
    '); // Replace images with HTML tag markdown = markdown.replace(/!\[(.*?)\]\((.*?)\)/gim, '$1'); // Replace links with HTML tag markdown = markdown.replace(/\[(.*?)\]\((.*?)\)/gim, '$1'); markdown = markdown.replaceAll("
        ", "") markdown = markdown.replaceAll("
    ", "") return markdown; } htmlToMarkdown(html) { // Replace headers (h1, h2, h3) with corresponding Markdown tags html = html.replace(/

    (.*?)<\/h1>/gim, '# $1'); html = html.replace(/

    (.*?)<\/h2>/gim, '## $1'); html = html.replace(/

    (.*?)<\/h3>/gim, '### $1'); // Replace bold and italic text with corresponding Markdown tags html = html.replace(/(.*?)<\/b>/gim, '**$1**'); html = html.replace(/(.*?)<\/i>/gim, '*$1*'); // Replace unordered list items with Markdown list tags html = html.replace(/