diff --git a/content_scripts/fairlang.js b/content_scripts/fairlang.js index a577c7b..573df6c 100644 --- a/content_scripts/fairlang.js +++ b/content_scripts/fairlang.js @@ -2,6 +2,12 @@ // Content script to be run on pages // --------------------------------- +function checkTextarea(textarea) { + console.log("click " + textarea.id + " -> " + textarea.value); + + // TODO make queries to the fairlanguage server +} + (function() { // Only run this script once if (window.hasRun) { @@ -11,9 +17,21 @@ // Search for all text areas document.querySelectorAll("textarea").forEach(function(textarea) { - // Do something with it... - console.log(textarea); + // for testing: highlight textarea with red border + // TODO textarea.style.border = "2px solid red"; - }); + // Create a "Check fairness" button which is placed next to the textarea + // TODO image button integrated into the textarea... + var buttonCheck = document.createElement("button"); + buttonCheck.textContent = "Check fairness!"; + + // Add click event listener + buttonCheck.addEventListener("click", (e) => { + checkTextarea(textarea); + }); + + // Append button to the textarea + textarea.after(buttonCheck); + }); })();