您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Calcule la moyenne à partir des matières et notes, y compris les images avec OCR
当前为
// ==UserScript== // ==UserScript== // @name Calculer Moyenne avec OCR sur École Directe // @namespace http://tampermonkey.net/ // @version 1.0 // @description Calcule la moyenne à partir des matières et notes, y compris les images avec OCR // @author Maxence // @match https://www.ecoledirecte.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=ecoledirecte.com // @grant none // ==/UserScript== (function() { 'use strict'; // Charger la bibliothèque Tesseract.js const script = document.createElement('script'); script.src = "https://cdn.jsdelivr.net/npm/[email protected]/dist/tesseract.min.js"; document.head.appendChild(script); script.onload = function() { // Attendre que la page soit complètement chargée setTimeout(() => { // Créer un bouton pour calculer la moyenne const avgButton = document.createElement("button"); avgButton.textContent = "Calculer la Moyenne 📊"; avgButton.style.fontSize = "16px"; avgButton.style.padding = "10px"; avgButton.style.position = "fixed"; avgButton.style.top = "20px"; avgButton.style.right = "20px"; avgButton.style.backgroundColor = "#4CAF50"; avgButton.style.color = "white"; avgButton.style.border = "none"; avgButton.style.borderRadius = "5px"; avgButton.style.cursor = "pointer"; document.body.appendChild(avgButton); // Fonction pour analyser les images avec OCR avgButton.addEventListener('click', () => { const images = Array.from(document.querySelectorAll('img')); // Sélectionner toutes les images const notes = []; const matières = []; images.forEach(image => { if (image.src) { // Utiliser Tesseract pour extraire le texte de l'image Tesseract.recognize(image.src, 'fra', { logger: (m) => console.log(m), }).then(({ data: { text } }) => { // Analyser le texte extrait const regexNote = /(\d+,\d+)/; // Recherche des notes au format numérique const regexMatière = /([A-Za-z]+|[A-Za-z]+\s[A-Za-z]+)/; // Recherche des matières const noteMatch = text.match(regexNote); const matièreMatch = text.match(regexMatière); if (noteMatch && matièreMatch) { matières.push(matièreMatch[0]); notes.push(parseFloat(noteMatch[0].replace(",", "."))); } // Si les matières et les notes ont été extraites, on calcule la moyenne if (matières.length > 0 && notes.length > 0) { const totalNotes = notes.reduce((sum, note) => sum + note, 0); const moyenne = totalNotes / notes.length; alert("Moyenne générale calculée : " + moyenne.toFixed(2)); } else { alert("Aucune matière ou note trouvée."); } }).catch(err => { console.error("Erreur lors de l'OCR", err); }); } }); }); }, 3000); // Attente avant de charger le bouton }; })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址