commit 159d371ec6e2f9a0f761f5fc7b1199a9b1676b33 Author: Lyanis Souidi Date: Mon Feb 13 15:28:20 2023 +0100 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..576ead8 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# WIMS Tester + +This extension modifies the [WIMS](https://en.wikipedia.org/wiki/WWW_Interactive_Multipurpose_Server) interface in order to be able to easily launch exercises on another server, this allows them to be tested without being graded. \ No newline at end of file diff --git a/_locales/ca/messages.json b/_locales/ca/messages.json new file mode 100644 index 0000000..75c17aa --- /dev/null +++ b/_locales/ca/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "Aquesta extensió modifica la interfície WIMS per tal de poder llançar fàcilment exercicis en un altre servidor, això permet provar-los sense ser qualificats." + }, + + "openOnServer": { + "message": "Obrir en el servidor " + }, + + "serverSelection": { + "message": "Servidor WIMS:" + }, + + "openCurrentPageOnServer": { + "message": "Obrir la pàgina actual en el servidor " + }, + + "save": { + "message": "Desar" + } +} \ No newline at end of file diff --git a/_locales/cn/messages.json b/_locales/cn/messages.json new file mode 100644 index 0000000..1649215 --- /dev/null +++ b/_locales/cn/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "此扩展修改了 WIMS 界面,以便能够轻松地在另一台服务器上启动练习,这使得它们可以在不评分的情况下进行测试。" + }, + + "openOnServer": { + "message": "在服务器上打开 " + }, + + "serverSelection": { + "message": "WIMS服务器:" + }, + + "openCurrentPageOnServer": { + "message": "在服务器上打开当前页面 " + }, + + "save": { + "message": "保存" + } +} \ No newline at end of file diff --git a/_locales/de/messages.json b/_locales/de/messages.json new file mode 100644 index 0000000..1688ff5 --- /dev/null +++ b/_locales/de/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "Diese Erweiterung modifiziert die WIMS-Schnittstelle, um Aufgaben einfach auf einem anderen Server starten zu können, sodass sie ohne Benotung getestet werden können." + }, + + "openOnServer": { + "message": "Öffnen auf Server " + }, + + "serverSelection": { + "message": "WIMS-Server:" + }, + + "openCurrentPageOnServer": { + "message": "Öffne aktuelle Seite auf Server " + }, + + "save": { + "message": "Speichern" + } +} \ No newline at end of file diff --git a/_locales/en/messages.json b/_locales/en/messages.json new file mode 100644 index 0000000..cccb596 --- /dev/null +++ b/_locales/en/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "This extension modifies the WIMS interface in order to be able to easily launch exercises on another server, this allows them to be tested without being graded." + }, + + "openOnServer": { + "message": "Open on server " + }, + + "serverSelection": { + "message": "WIMS server:" + }, + + "openCurrentPageOnServer": { + "message": "Open current page on server " + }, + + "save": { + "message": "Save" + } +} \ No newline at end of file diff --git a/_locales/es/messages.json b/_locales/es/messages.json new file mode 100644 index 0000000..bf78f52 --- /dev/null +++ b/_locales/es/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "Esta extensión modifica la interfaz de WIMS para poder lanzar ejercicios fácilmente en otro servidor, esto permite que sean evaluados sin ser calificados." + }, + + "openOnServer": { + "message": "Abrir en el servidor " + }, + + "serverSelection": { + "message": "servidor WIMS:" + }, + + "openCurrentPageOnServer": { + "message": "Abrir la página actual en el servidor " + }, + + "save": { + "message": "Guardar" + } +} \ No newline at end of file diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json new file mode 100644 index 0000000..a2b2956 --- /dev/null +++ b/_locales/fr/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "Cette extension modifie l'interface WIMS afin de pouvoir lancer facilement des exercices sur un autre serveur, cela permet de les tester sans être notés." + }, + + "openOnServer": { + "message": "Ouvrir sur le serveur " + }, + + "serverSelection": { + "message": "Serveur WIMS :" + }, + + "openCurrentPageOnServer": { + "message": "Ouvrir la page actuelle sur le serveur " + }, + + "save": { + "message": "Enregistrer" + } +} \ No newline at end of file diff --git a/_locales/it/messages.json b/_locales/it/messages.json new file mode 100644 index 0000000..a760b8e --- /dev/null +++ b/_locales/it/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "Questa estensione modifica l'interfaccia WIMS per poter lanciare facilmente gli esercizi su un altro server, questo permette loro di essere testati senza essere valutati." + }, + + "openOnServer": { + "message": "Apri sul server " + }, + + "serverSelection": { + "message": "Server WIMS:" + }, + + "openCurrentPageOnServer": { + "message": "Apri la pagina attuale sul server " + }, + + "save": { + "message": "Salva" + } +} \ No newline at end of file diff --git a/_locales/jp/messages.json b/_locales/jp/messages.json new file mode 100644 index 0000000..e09b987 --- /dev/null +++ b/_locales/jp/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "この拡張機能は、WIMS インターフェイスを変更して、別のサーバーで演習を簡単に開始できるようにします。これにより、採点せずにテストすることができます。" + }, + + "openOnServer": { + "message": "サーバー上で開く " + }, + + "serverSelection": { + "message": "WIMS サーバー:" + }, + + "openCurrentPageOnServer": { + "message": "サーバー上で現在のページを開く " + }, + + "save": { + "message": "保存する" + } +} diff --git a/_locales/nl/messages.json b/_locales/nl/messages.json new file mode 100644 index 0000000..558d507 --- /dev/null +++ b/_locales/nl/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "Deze extensie past de WIMS-interface aan om oefeningen gemakkelijk op een andere server te kunnen starten, waardoor ze kunnen worden getest zonder dat ze worden beoordeeld." + }, + + "openOnServer": { + "message": "Openen op server " + }, + + "serverSelection": { + "message": "WIMS-server:" + }, + + "openCurrentPageOnServer": { + "message": "Open huidige pagina op server " + }, + + "save": { + "message": "Opslaan" + } +} \ No newline at end of file diff --git a/_locales/si/messages.json b/_locales/si/messages.json new file mode 100644 index 0000000..08d459d --- /dev/null +++ b/_locales/si/messages.json @@ -0,0 +1,21 @@ +{ + "extensionDescription": { + "message": "Toto rozšírenie upravuje rozhranie WIMS, aby bolo možné ľahko spúšťať cvičenia na inom serveri, čo umožňuje ich testovanie bez hodnotenia." + }, + + "openOnServer": { + "message": "Otvoriť na serveri " + }, + + "serverSelection": { + "message": "WIMS server:" + }, + + "openCurrentPageOnServer": { + "message": "Otvoriť aktuálnu stránku na serveri " + }, + + "save": { + "message": "Uložiť" + } +} \ No newline at end of file diff --git a/icons/128-dark.png b/icons/128-dark.png new file mode 100644 index 0000000..90dff61 Binary files /dev/null and b/icons/128-dark.png differ diff --git a/icons/128-light.png b/icons/128-light.png new file mode 100644 index 0000000..26aa291 Binary files /dev/null and b/icons/128-light.png differ diff --git a/icons/16-dark.png b/icons/16-dark.png new file mode 100644 index 0000000..b1accfe Binary files /dev/null and b/icons/16-dark.png differ diff --git a/icons/16-light.png b/icons/16-light.png new file mode 100644 index 0000000..9dc7c77 Binary files /dev/null and b/icons/16-light.png differ diff --git a/icons/32-dark.png b/icons/32-dark.png new file mode 100644 index 0000000..6f6386e Binary files /dev/null and b/icons/32-dark.png differ diff --git a/icons/32-light.png b/icons/32-light.png new file mode 100644 index 0000000..c6b37ad Binary files /dev/null and b/icons/32-light.png differ diff --git a/icons/48-dark.png b/icons/48-dark.png new file mode 100644 index 0000000..73ab69e Binary files /dev/null and b/icons/48-dark.png differ diff --git a/icons/48-light.png b/icons/48-light.png new file mode 100644 index 0000000..60515b2 Binary files /dev/null and b/icons/48-light.png differ diff --git a/icons/96-dark.png b/icons/96-dark.png new file mode 100644 index 0000000..bf2a695 Binary files /dev/null and b/icons/96-dark.png differ diff --git a/icons/96-light.png b/icons/96-light.png new file mode 100644 index 0000000..7c4f3cb Binary files /dev/null and b/icons/96-light.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..d64e23d --- /dev/null +++ b/index.html @@ -0,0 +1,24 @@ + + + + + WIMS Tester + + + +

WIMS Tester

+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/inject.js b/inject.js new file mode 100644 index 0000000..f09bd35 --- /dev/null +++ b/inject.js @@ -0,0 +1,47 @@ +function createLink(name, oldURL, newURL) { + let e = document.createElement("a"); + e.className = "_wims_tester_link"; + e.innerText = "[" + browser.i18n.getMessage("openOnServer") + `'${name}']`; + let link = new URL(newURL); + link.search = new URL(oldURL).search; + e.href = link.toString(); + e.target = "_blank"; + return e; +} + +function updateLink(e, name, url) { + e.innerText = "[" + browser.i18n.getMessage("openOnServer") + `'${name}']`; + let link = new URL(url); + link.search = new URL(e.href).search; + e.href = link.toString(); +} + +async function load() { + let serversList = await fetch(browser.runtime.getURL("servers.json")).then((response) => response.json()).then((data) => data["servers"]); + let preferredServer = await browser.storage.sync.get('preferredServer').then(item => item.preferredServer); + if (typeof preferredServer === "undefined" || !preferredServer.hasOwnProperty("url")) preferredServer = serversList[0]; + + let list = document.getElementsByClassName("wims_exo_item"); + for (let item of list) item.firstElementChild.after(createLink(preferredServer.name, item.firstElementChild.href, preferredServer.url)); + + list = document.querySelectorAll('a[target="wims_exo"]'); + for (let item of list) item.after(createLink(preferredServer.name, item.href, preferredServer.url)); + + list = document.querySelectorAll('ul[class="wims_home_result_list"] > li'); + for (let item of list) item.firstElementChild.after(createLink(preferredServer.name, item.firstElementChild.href, preferredServer.url)); +} + +let style = document.createElement('style'); +style.textContent = "._wims_tester_link::before { content: ' '; } ._wims_tester_link { font-size: small; color: black; }"; +document.head.append(style); + +load(); + +browser.storage.sync.onChanged.addListener((changes) => { + const changedItems = Object.keys(changes); + for (const item of changedItems) { + if (item == "preferredServer") { + document.querySelectorAll('a[class="_wims_tester_link"]').forEach(e => updateLink(e, changes[item].newValue.name, changes[item].newValue.url)); + } + } +}); \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..22fcff6 --- /dev/null +++ b/manifest.json @@ -0,0 +1,61 @@ +{ + "manifest_version": 2, + "name": "WIMS Tester", + "author": "Lyanis Souidi", + "version": "1.0", + "browser_specific_settings": { + "gecko": { + "id": "wims-tester@lyanis.sh" + } + }, + "description": "__MSG_extensionDescription__", + "homepage_url": "https://github.com/lyanissouidi/wims-tester", + "default_locale": "en", + "browser_action": { + "default_title": "WIMS Tester", + "default_popup": "index.html", + "browser_style": true, + "default_icon": { + "16": "icons/16-light.png", + "32": "icons/32-light.png", + "48": "icons/48-light.png", + "96": "icons/96-light.png", + "128": "icons/128-light.png" + }, + "theme_icons": [{ + "light": "icons/16-light.png", + "dark": "icons/16-dark.png", + "size": 16 + }, { + "light": "icons/32-light.png", + "dark": "icons/32-dark.png", + "size": 32 + }, { + "light": "icons/48-light.png", + "dark": "icons/48-dark.png", + "size": 48 + }, { + "light": "icons/96-light.png", + "dark": "icons/96-dark.png", + "size": 96 + }, { + "light": "icons/128-light.png", + "dark": "icons/128-dark.png", + "size": 128 + }] + }, + "content_scripts": [ + { + "matches": ["*://*/*wims.cgi*"], + "js": ["inject.js"] + } + ], + "permissions": ["tabs", "storage"], + "icons": { + "16": "icons/16-light.png", + "32": "icons/32-light.png", + "48": "icons/48-light.png", + "96": "icons/96-light.png", + "128": "icons/128-light.png" + } +} \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..1c45d3f --- /dev/null +++ b/script.js @@ -0,0 +1,37 @@ +document.getElementsByTagName("legend")[0].innerText = browser.i18n.getMessage("serverSelection"); +async function updateLink(name, url) { + let link = new URL(url); + let tabURL = await browser.tabs.query({currentWindow: true, active: true}).then(tabs => tabs[0].url); + link.search = new URL(tabURL).search; + let a = document.getElementsByTagName("a")[0]; + a.href = link.toString(); + a.innerText = browser.i18n.getMessage("openCurrentPageOnServer") + `'${name}'`; +} + +async function load(qualifiedName, value) { + let serversList = await fetch(browser.runtime.getURL("servers.json")).then((response) => response.json()).then((data) => data["servers"]); + let preferredServer = await browser.storage.sync.get('preferredServer').then(item => item.preferredServer); + if (typeof preferredServer === "undefined" || !preferredServer.hasOwnProperty("url")) preferredServer = serversList[0]; + for (let i = 0; i < serversList.length; i++) { + let div = document.createElement("div"); + let input = document.createElement("input"); + input.type = "radio"; + input.id = serversList[i].url; + input.name = "server"; + input.value = serversList[i].name; + if (preferredServer.url === serversList[i].url) input.checked = true; + input.addEventListener("click", saveServer); + div.appendChild(input); + let label = document.createElement("label"); + label.for = serversList[i].name; + label.innerText = serversList[i].name; + div.appendChild(label); + document.getElementById("servers").appendChild(div); + } + updateLink(preferredServer.name, preferredServer.url); +} +load(); +function saveServer(e) { + browser.storage.sync.set({ preferredServer: { name: e.target.value, url: e.target.id } }); + updateLink(e.target.value, e.target.id); +} diff --git a/servers.json b/servers.json new file mode 100644 index 0000000..cf1865a --- /dev/null +++ b/servers.json @@ -0,0 +1,64 @@ +{ + "servers": [ + { + "name": "Université Côte d'Azur", + "url": "https://wims.univ-cotedazur.fr/wims/wims.cgi" + }, + { + "name": "CNRS", + "url": "https://wims.math.cnrs.fr/wims/wims.cgi" + }, + { + "name": "Université Caen Normandie", + "url": "https://wims.unicaen.fr/wims/wims.cgi" + }, + { + "name": "Université Sorbonne Paris Nord", + "url": "https://sercalwims.ig-edu.univ-paris13.fr/wims/wims.cgi" + }, + { + "name": "Université Paris-Saclay", + "url": "https://wimsauto.universite-paris-saclay.fr/wims/wims.cgi" + }, + { + "name": "Aix-Marseille Université", + "url": "https://wims.univ-mrs.fr/wims/wims.cgi" + }, + { + "name": "Université de Picardie", + "url": "https://www.u-picardie.fr/wims/wims.cgi" + }, + { + "name": "Académie de Versailles", + "url": "https://euler-ressources.ac-versailles.fr/wims/wims.cgi" + }, + { + "name": "Université de Nice", + "url": "http://wims.espe-nice-toulon.fr/wims/wims.cgi" + }, + { + "name": "Université Littoral Côte d'Opale", + "url": "http://wims.univ-littoral.fr/wims/wims.cgi" + }, + { + "name": "Lycée polyvalent Diderot Paris", + "url": "http://www.f-lasne.com/wims/wims.cgi" + }, + { + "name": "Università degli Studi di Milano-Bicocca", + "url": "https://wims.matapp.unimib.it/wims/wims.cgi" + }, + { + "name": "Universitat Rovira i Virgili", + "url": "http://wims-deq.urv.cat/wims/wims.cgi" + }, + { + "name": "Xarxa Telemàtica Educativa de Catalunya", + "url": "http://insbaixpenedes.xtec.cat/wims/wims.cgi" + }, + { + "name": "Uniwersytet Mikołaja Kopernika", + "url": "https://cosmo.astro.uni.torun.pl/wims/wims.cgi" + } + ] +} \ No newline at end of file