SQLCoach Fixer

10.12.2022, 12:58:58

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        SQLCoach Fixer
// @namespace   Violentmonkey Scripts
// @match       *://sqlcoach.informatik.hs-kl.de/*
// @grant       none
// @version     1.25
// @author      DJOetzi
// @license GPL-3.0-or-later; https://www.gnu.org/licenses/gpl-3.0.txt
// @description 10.12.2022, 12:58:58
// ==/UserScript==

document.querySelector('[value="SQL Überprüfen"]').addEventListener('click', function(){
  let cache = document.getElementById("query").value
  //console.log(cache)
  localStorage.setItem("sqlcoach_iocache", cache)
})

document.body.onload = function(){
  let handle = document.getElementById("query")
  handle.removeAttribute("type")
  handle.setAttribute("style", `@import url('https://fonts.cdnfonts.com/css/cascadia-code'); font-family: 'Cascadia Code', "consolas", sans-serif; border-radius: 5px;`)
  handle.setAttribute("spellcheck", "false")
  handle.outerHTML = handle.outerHTML.replace("input", "textarea")
  //console.log(localStorage.getItem("sqlcoach_iocache"))
  console.log("SQLCoach Fixer successfully loaded initial setup!")
}

window.addEventListener('load', function() {
    document.getElementById("query").innerHTML = localStorage.getItem("sqlcoach_iocache")
}, false);

let syntaxFixer = function(){
  let tmp = document.getElementById("query")
  if(tmp.innerHTML.includes(";"))
    tmp.innerHTML = tmp.innerHTML.replace(";", " ")
}

document.querySelector('[value="SQL Überprüfen"]').onmouseover = syntaxFixer;
document.querySelector('[value="SQL Überprüfen"]').onmousedown = syntaxFixer;