38 lines
995 B
JavaScript
38 lines
995 B
JavaScript
// ---------------------------------
|
|
// 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) {
|
|
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);
|
|
});
|
|
})();
|