Skip to content

Instantly share code, notes, and snippets.

@Foso
Created November 12, 2021 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Foso/5c793a99bc2e1ac37b6811a932adefa2 to your computer and use it in GitHub Desktop.
Save Foso/5c793a99bc2e1ac37b6811a932adefa2 to your computer and use it in GitHub Desktop.
add syntax highlighting to Qase
// ==UserScript==
// @name Qase Gherkin
// @version 0.1
// @description add syntax highlighting to Qase
// @author github.com/foso
// @match https://app.qase.io/run/*
// @match https://app.qase.io/case/*
// @match https://app.qase.io/project/APP20*
// @icon https://qase.io/favicon.png
// @grant none
// ==/UserScript==
var oldText = "";
var observer = new MutationObserver(function (mutations, me) {
var editorContent = document.querySelector('.toastui-editor-contents');
if (editorContent) {
var newText = editorContent.innerHTML;
if(newText !=oldText){
editorContent.innerHTML = editorContent.innerHTML
.replaceAll("And ","<span style=\"color:blue;font-weight:bold\">And</span> ")
.replaceAll("But ","<span style=\"color:blue;font-weight:bold\">But</span> ")
.replaceAll("When ","<b>When</b> ")
.replaceAll("Given ","<b>Given</b> ")
.replaceAll("Then ","<b>Then</b> ")
.replaceAll("Scenario: ","<b>Scenario:</b> ");
oldText = newText;
}
return;
}
});
// start observing
observer.observe(document, {
childList: true,
subtree: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment