// --------------------------------- // Content script to be run on pages // --------------------------------- function checkTextarea(textarea) { console.log("click " + textarea.id + " -> " + textarea.value); // TODO make queries to the fairlanguage server fetch("https://fairlanguage2.dev-star.de/checkDocument?data=liebe+Bürger&json") .then(response => response.json()) .then(response => { console.log(response); }) .catch(error => console.log(error)); } (function() { // Only run this script once if (window.hasRun) { return; } window.hasRun = true; // Search for all text areas document.querySelectorAll("textarea").forEach(function(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); }); })();