您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
11/10/2023 18:50:40
当前为
// ==UserScript== // @name Better-Devinci // @namespace Violentmonkey Scripts // @match https://www.leonard-de-vinci.net/* // @match https://learning.devinci.fr/* // @grant none // @version 3.0.2 // @author Better-Devinci // @license GNU GPLv3 // @run-at document-start // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @description 11/10/2023 18:50:40 // ==/UserScript== //beginning IIFE (function () { 'use strict'; let betterdevinciactualversion = "3.0.2"; if(localStorage.getItem("Version_Better_Devinci")!=undefined){ localStorage.clear() } let CheckGM= function(Item,Base_value){ if(GM_getValue(Item)===undefined){ GM_setValue(Item,Base_value) } } CheckGM("Version_Better_Devinci",betterdevinciactualversion) CheckGM("Hide_Slider",false) CheckGM("Number_Message_read",0) CheckGM("Footer&Scrollbar",true) CheckGM("Notification",true) CheckGM("SideBar_Diminish",false) CheckGM("Hide_news",true) CheckGM("Better_Marks",true) CheckGM("Finished_Sport_Inscription",false) CheckGM("Dark_Mode",false) if(betterdevinciactualversion!=GM_getValue("Version_Better_Devinci")){ GM_setValue("Version_Better_Devinci",betterdevinciactualversion) } console.log("beginning run start") let BasicStyle=` :root{ --main-bg-color: black; --main-color : red; } #main { padding-bottom: 0px!important; } #Slider_Button:active { background-color: #a0c7e4; box-shadow: none; color: #2c5777; } #Slider_Button { background-color: #e1ecf4; border-radius: 3px; border: 1px solid #7aa7c7; box-shadow: rgba(255, 255, 255, .7) 0 1px 0 0 inset; box-sizing: border-box; color: #39739d; cursor: pointer; display: inline-block; font-family: -apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif; font-size: 13px; font-weight: 400; line-height: 1.15385; margin: 0; outline: none; position: relative; text-align: center; text-decoration: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; vertical-align: baseline; white-space: nowrap; } #Slider_Button:hover{ background-color: #b3d3ea; color: #2c5777; } #Slider_Button:focus { box-shadow: 0 0 0 4px rgba(0, 149, 255, .15); } `; GM_addStyle(BasicStyle) function Portal_Setup(){ if(GM_getValue("Dark_Mode")){ let DarkMode = ` .dd-module > .dd-handle{ color:white!important; } .dd-unite-student> .dd-handle{ color:blue!important; } .dd-unite-student> .dd-handle{ color:blue!important; } .dd-unite-student { background-color: #54545566; } .dd-handle { color:var(--main-color)!important; background: var(--main-bg-color)!important; } .b-dayview-day-container .b-calendar-cell.b-nonworking-day { background-color: #54545566!important; } .dropdown-menu>li>a { color:var(--main-color)!important } .nav-indicators .nav-messages .dropdown-menu li { border-top: 0px!important; } .nav-indicators .nav-messages .dropdown-menu .nav-messages-footer { background-color: var(--main-bg-color)!important; } .nav-indicators .nav-messages .dropdown-menu .nav-messages-header>a, .nav-indicators .nav-messages .dropdown-menu .nav-messages-header>a:hover, .nav-indicators .nav-messages .dropdown-menu .nav-messages-header>a:focus { color: var(--main-color)!important; } .nav-indicators .nav-messages .dropdown-menu .nav-messages-header {background-color: var(--main-bg-color)!important;} .panel { background-color: var(--main-bg-color)!important; } .site-menu-title{ color:var(--main-color)!important; } .site-menu{ background-color:var(--main-bg-color)!important; } .dropdown-menu{ background-color:var(--main-bg-color)!important; } .breadcrumb{ color:var(--main-color)!important; background-color:var(--main-bg-color)!important; } .breadcrumb.no_margin{ border:0px; } .site-menu-icon{ color:var(--main-color)!important; } .navbar-fixed-top{ margin:0px; } .b-toolbar { background-color:var(--main-bg-color)!important; } .b-daycellcollecter .b-dayview-content { background-color:var(--main-bg-color)!important; } .b-dayview-day-container .b-calendar-cell:not(.b-last-cell) { border-right: 0px!important; } .b-dayview-day-container { border-left: 0px!important; background-image:none!important; } .b-calendarrow .b-cal-cell-header { background-color: var(--main-bg-color)!important; } .social-box { background-color: var(--main-bg-color)!important; } body{ background-color:var(--main-bg-color)!important; color:var(--main-color)!important; } .b-panel>.b-panel-body-wrap{ background-color:var(--main-bg-color)!important; } `; GM_addStyle(DarkMode); } if(GM_getValue("SideBar_Diminish")){ if(document.querySelector(".social-sidebar"+".sidebar-full")){ document.querySelector(".wraper"+".page-content"+".sidebar-full").className="wraper page-content" document.querySelector("body").style.overflowX='auto' document.querySelector("body").querySelector(".wraper"+".page-content").className = 'wraper page-content' document.querySelector(".social-sidebar").className = 'social-sidebar' } } if(GM_getValue("Footer&Scrollbar")){ document.querySelector('html').style.height="0px" //remove the scrollbar when not necessary if(document.querySelector('#footer')){ document.querySelector('#footer').remove() } } let MessageRead_Button = document.createElement("button"); MessageRead_Button.id = "Message_Read_Button"; MessageRead_Button.textContent = "Show Messages as read"; MessageRead_Button.style.color= 'red' MessageRead_Button.addEventListener("click", function() { GM_setValue("Number_Message_read",parseInt(document.querySelector('.UD_messages_new').innerText)) console.log("number message read:"+GM_getValue("Number_Message_read")) document.querySelector('.UD_messages_new').remove() document.querySelector(".UD_messages_new"+".strong").innerText=0 MessageRead_Button.remove() }) if(GM_getValue("Notification")) { console.log("notif") if(document.querySelector('.UD_messages_new'+'.badge')){ if(parseInt(document.querySelector('.UD_messages_new'+'.badge').innerText)==GM_getValue("Number_Message_read")){ document.querySelector('.UD_messages_new'+'.badge').remove() document.querySelector(".UD_messages_new"+".strong").innerText=0 } } } const BetterDevinci_link = document.createElement("a"); BetterDevinci_link.id = "BetterDevinci_link" BetterDevinci_link.setAttribute("href", "/?my=msg&Better-Devinci"); BetterDevinci_link.textContent = "+"; BetterDevinci_link.style.color = 'red' BetterDevinci_link.style.fontWeight='bold' BetterDevinci_link.style.fontSize='20px' if(document.querySelector(".navbar-inner-title")){ document.querySelector(".navbar-inner-title").append(BetterDevinci_link) } if(document.querySelector(".social-sidebar"+".sidebar-full")!=null && GM_getValue("SideBar_Diminish")){ document.querySelector(".switch-sidebar-icon"+".icon-align-justify").click() } let observer_Page = new MutationObserver(function (mutationsList, observer) { for (var mutation of mutationsList) { if (mutation.type === 'childList') { for (var node of mutation.addedNodes) { if (node.nodeType === Node.ELEMENT_NODE ) { //console.log(node) if(node.matches('#footer') && GM_getValue("Footer&Scrollbar")){ node.remove() } else if(node.matches('.UD_messages_new'+'.badge') && node.innerText==GM_getValue("Number_Message_read") && GM_getValue("Notification")){ node.remove() } else if(node.matches(".nav-messages-header") && GM_getValue("Notification")){ if(document.querySelector('.UD_messages_new'+'.badge')!=undefined){ node.append(MessageRead_Button) } } else if(node.matches(".UD_messages_new"+".strong")&& node.innerText==GM_getValue("Number_Message_read") && GM_getValue("Notification")){ node.innerText=0 } else if(node.matches(".navbar-inner-title")){ node.append(BetterDevinci_link) } else if(node.innerText.includes("let posting = $.ajax({\n")){ node.innerHTML=node.innerHTML.replace('let posting = $.ajax({\n ',"var posting = $.ajax({\n ") } else if(GM_getValue("SideBar_Diminish")){ if(node.matches(".wraper"+".page-content"+".sidebar-full")){ node.classname='wraper page-content' document.querySelector("body").querySelector(".wraper"+".page-content").className = 'wraper page-content' } else if(node.matches(".social-sidebar"+".sidebar-full")){ node.className = 'social-sidebar' document.querySelector("body").querySelector(".wraper"+".page-content").className = 'wraper page-content' } else if(node.matches("body")){ node.style.overflowX='auto' document.querySelector("body").querySelector(".wraper"+".page-content").className = 'wraper page-content' } } } } } } }); observer_Page.observe(document, { childList: true, subtree: true }); } function BetterDevinci_Page(){ let Rewrite_Container = document.createElement("div"); Rewrite_Container.id = "OwO"; Rewrite_Container.style.margin='10px' Rewrite_Container.style.paddingLeft='10px' const TextPresentation=document.createElement("div"); TextPresentation.textContent = "This page is still in beta, it lists everything Better-Devinci does and you can activate or deactivate it"; TextPresentation.style.color= 'red' TextPresentation.style.marginBottom='20px' Rewrite_Container.append(TextPresentation) const data = [ { name: 'Footer&Scrollbar', description: 'Removes the footer. The scrollbar when useful' }, { name: 'Notification', description: "Adds a button to mark all messages as read since it's bugged..."}, { name: 'Hide_news', description: 'Adds the ability to hide & unhide the news panel with a button' }, { name: 'Better_Marks', description: 'Adds the ability to diminish by semester and module the marks' }, { name: 'SideBar_Diminish', description: 'Diminish the sidebar when useful to have more place on the page' }, { name: "Dark_Mode",description: 'Enables the dark mode for the portal (refresh to apply changes)'} ] const table = document.createElement('table'); const headerRow = document.createElement('tr'); const nameHeaderCell = document.createElement('th'); nameHeaderCell.textContent = 'Name'; nameHeaderCell.style.height='50px' nameHeaderCell.style.width='200px' //headerRow.appendChild(nameHeaderCell); const descriptionHeaderCell = document.createElement('th'); descriptionHeaderCell.textContent = 'Description'; headerRow.appendChild(descriptionHeaderCell); const checkboxHeaderCell = document.createElement('th'); checkboxHeaderCell.textContent = 'Checkbox'; headerRow.appendChild(checkboxHeaderCell); table.appendChild(headerRow); data.forEach(item => { const row = document.createElement('tr'); const descriptionCell = document.createElement('td'); descriptionCell.textContent = item.description; descriptionCell.style.textAlign = 'center'; row.appendChild(descriptionCell); const checkboxCell = document.createElement('td'); checkboxCell.style.display = 'flex' checkboxCell.style.justifyContent = 'center'; const checkbox = document.createElement('input'); checkbox.className='better-devinci-checkbox' checkbox.type = 'checkbox'; checkboxCell.appendChild(checkbox); row.appendChild(checkboxCell); if(GM_getValue(item.name)) { checkbox.checked = true; } checkbox.addEventListener('change', function() { if (GM_getValue(item.name)) { GM_setValue(item.name,false) } else{ GM_setValue(item.name,true) } }); table.appendChild(row); }); Rewrite_Container.append(table); if(document.querySelector("#main") && document.querySelector("#main").querySelectorAll(".container-fluid")){ document.querySelector("#main").querySelectorAll(".container-fluid")[1].remove() } if(document.querySelector("#main")){ console.log("inserted before observer") document.querySelector("#main").append(Rewrite_Container) } //document.querySelector("#main").querySelectorAll(".container-fluid")[1].remove() let observer_Page = new MutationObserver(function (mutationsList, observer) { for (var mutation of mutationsList) { if (mutation.type === 'childList') { for (var node of mutation.addedNodes) { if (node.nodeType === Node.ELEMENT_NODE ) { if(node.matches(".container-fluid") && node.parentElement.matches("#main")){ if(node.parentElement.childElementCount==2){ document.querySelector("#main").append(Rewrite_Container) } node.remove() } } } } } }); observer_Page.observe(document, { childList: true, subtree: true }); } function Marks(){ let observer_Page = new MutationObserver(function (mutationsList, observer) { for (var mutation of mutationsList) { if (mutation.type === 'childList') { for (var node of mutation.addedNodes) { if (node.nodeType === Node.ELEMENT_NODE) { if (node.classList.toString().includes("dd-handle") && !node.parentElement.classList.toString().includes("dd-module") && !node.parentElement.classList.toString().includes("entry_elements")) { //console.log("applying for element ", node) node.onclick = (e) => { //console.log("clicked on ", e.target); let target = e.target; while (target.classList != "dd-handle") { target = target.parentElement } console.log("acting on", target); [...target.parentElement.children].forEach((child) => { if (child.classList.toString().includes("dd-list")) { if (!child.classList.toString().includes("hide")) { child.classList.add("hide") } else child.classList.remove("hide") } }) } } } } } } }); observer_Page.observe(document, { childList: true, subtree: true }); } function MainPage(){ console.log("beg") let SliderButton = document.createElement("button"); SliderButton.id = "Slider_Button"; SliderButton.textContent = "Hide News"; SliderButton.addEventListener("click", function() { if(GM_getValue("Hide_Slider")==false){ SliderButton.innerHTML="Show News" SliderButton.nextElementSibling.className+=' hide' GM_setValue("Hide_Slider",true) } else{ SliderButton.innerHTML="Hide News" SliderButton.nextElementSibling.className=SliderButton.nextElementSibling.className.replace(" hide","") GM_setValue("Hide_Slider",false) } }) if(GM_getValue("Hide_news")){ const Body = document.querySelector(".body") if(Body && Body.parentElement && Body.parentElement.parentElement){ console.log("prepended without mutator") if(GM_getValue("Hide_Slider")){ SliderButton.innerHTML="Show News" Body.parentElement.className+=' hide' } Body.parentElement.parentElement.prepend(SliderButton); } } let observer_Page = new MutationObserver(function (mutationsList, observer) { for (var mutation of mutationsList) { if (mutation.type === 'childList') { for (var node of mutation.addedNodes) { if (node.nodeType === Node.ELEMENT_NODE ) { if(node.matches(".alert"+".alert-success") && node.innerText.includes("Vous êtes maintenant réinscrit(e)")){ node.parentElement.parentElement.parentElement.remove() } else if(node.matches('.social-box') && node.className==='social-box'){ if(GM_getValue("Hide_Slider")){ SliderButton.innerHTML="Show News" node.className+=' hide' } node.parentElement.prepend(SliderButton); } } } } } }); observer_Page.observe(document, { childList: true, subtree: true }); console.log("end") } function Presence(){ if(document.querySelector(".icon-question-sign") && document.querySelector(".icon-question-sign")){ document.querySelector(".icon-question-sign").parentElement.remove() } let observer_Page = new MutationObserver(function (mutationsList, observer) { for (var mutation of mutationsList) { if (mutation.type === 'childList') { for (var node of mutation.addedNodes) { if (node.nodeType === Node.ELEMENT_NODE ) { if(node.matches('.alert'+'.alert-info') && node.innerText===' Pour accéder aux détails de la séance et à la validation de présence, cliquez sur le bouton "Relevé de présence".'){ node.remove() } } } } } }); observer_Page.observe(document, { childList: true, subtree: true }); } function CheckPage(){ if(location.href.includes("www.leonard-de-vinci.net/")){ console.log("portal setup") Portal_Setup() if(location.href === "https://www.leonard-de-vinci.net/"){ console.log("mainpage") MainPage() } else if(location.href === "https://www.leonard-de-vinci.net/?my=msg&Better-Devinci"){ BetterDevinci_Page() } else if(location.href === "https://www.leonard-de-vinci.net/?my=marks"){ Marks() } //else if(location.href.includes("https://www.leonard-de-vinci.net/?my=msg")){ // Message() //} else if(location.href === "https://www.leonard-de-vinci.net/student/presences/"){ console.log("presence") Presence() } //else if(location.href === "https://www.leonard-de-vinci.net/student/sport/"){ // Sports() //} } else if(location.href.includes("https://learning.devinci.fr")){ //Page_learning_devinci() if(location.href.includes("https://learning.devinci.fr/course/view.php?id=")||location.href.includes("https://learning.devinci.fr/mod") && !location.href.includes("https://learning.devinci.fr/mod/forum")){ Courses() } else if(location.href == "https://learning.devinci.fr/my/"){ Learning_Main_Page() } } } CheckPage() function Learning_Main_Page(){ let BasicStyle=` .card-body .p-3{ padding-top:0px!important; } #topofscroll{ margin:0px!important; } `; GM_addStyle(BasicStyle) /* document.querySelector("#topofscroll").parentElement.appendChild(document.querySelector("#inst3124")) document.querySelector("#page-header").remove() document.querySelector("#inst174").remove() document.querySelector("#instance-2524-header").remove() document.querySelector(".mt-0").remove() //document.querySelector('[data-region="course-content"]').parentElement.style.gap='5px' // maybe important later /*let intervalLearning_Main_Page=setInterval(function(){ if(document.querySelectorAll(".dashboard-card-footer").length!=0){ document.querySelectorAll(".dashboard-card-footer").forEach(function(UwU){UwU.remove()}) document.querySelectorAll(".muted").forEach(function(UwU){UwU.remove()}) document.querySelectorAll('[data-region="course-content"]').forEach(function(UwU){ UwU.style.margin='0px' UwU.style.paddingBottom='0px' }) document.querySelectorAll(".multiline").forEach(function(UwU){ if(UwU.innerText.match(/\s\([a-zA-Z0-9-]+\)/g)){ UwU.innerText=UwU.innerText.replace(UwU.innerText.match(/\s\([a-zA-Z0-9-]+\)/g)[0],"") } }) document.getElementsByClassName(" block_courses_discover block card mb-3")[0].remove() clearInterval(intervalLearning_Main_Page) } }, 20)*/ let observer_LMP = new MutationObserver(function (mutationsList, observer) { //console.log("observer") for (let mutation of mutationsList) { if (mutation.type === 'childList' ) { //console.log("passed childlist") // Check if added nodes match the criteria for (let node of mutation.addedNodes) { if(node.nodeType === Node.ELEMENT_NODE){ if(node.matches('[data-region="paged-content-page"]') && document.querySelectorAll(".dashboard-card-footer").length!=0) { document.querySelectorAll(".dashboard-card-footer").forEach(function(UwU){UwU.remove()}) document.querySelectorAll(".muted").forEach(function(UwU){UwU.remove()}) document.querySelectorAll('[data-region="course-content"]').forEach(function(UwU){ UwU.style.margin='0px' UwU.style.paddingBottom='0px' }) document.querySelectorAll(".multiline").forEach(function(UwU){ if(UwU.innerText.match(/\s\([a-zA-Z0-9-]+\)/g)){ UwU.innerText=UwU.innerText.replace(UwU.innerText.match(/\s\([a-zA-Z0-9-]+\)/g)[0],"") } }) if(document.getElementsByClassName(" block_courses_discover block card mb-3") && document.getElementsByClassName(" block_courses_discover block card mb-3")[0]){ document.getElementsByClassName(" block_courses_discover block card mb-3")[0].remove() } } else if(node.matches("#page-header") || node.matches("#inst174") || node.matches("#instance-2524-header") || node.matches(".mt-0")){ node.remove() } else if(node.matches("#inst3124")){ node.remove() //node.parentElement.appendChild(node) //console.log(document.querySelector("#topofscroll")) } } } } } }); observer_LMP.observe(document, { childList: true, subtree: true }); } function Courses(){ let observer_Courses = new MutationObserver(function (mutationsList, observer) { for (let mutation of mutationsList) { if (mutation.type === 'childList' ) { for (let node of mutation.addedNodes) { if(node.nodeType === Node.ELEMENT_NODE){ if(node.matches('#resourceobject'+'[type="application/pdf"]')){ console.log("pdf here") let OpenPdf = document.createElement("button"); OpenPdf.id = "OpenPdf" OpenPdf.textContent = "Open Pdf"; OpenPdf.className="btn" OpenPdf.style.color='red' let interval_Pdf=setInterval(function(){ if(document.querySelector("#focus-navigation-buttons-start")){ document.querySelector("#focus-navigation-buttons-start").prepend(OpenPdf) clearInterval(interval_Pdf) } }, 20) OpenPdf.addEventListener("click", function() { window.open(document.querySelector('#resourceobject'+'[type="application/pdf"]').data) }) } else if(node.matches(".no-announces")){ if(node.innerText==="Vous n'avez pas d'annonce disponible"){ node.parentElement.previousElementSibling.remove() node.remove() } } else if(node.matches(".container"+ ".focus-completion")){ node.remove() } else if(node.innerHTML.includes("restrictions")){ let HideLockedButton = document.createElement("button"); HideLockedButton.id = "HideLockedButton"; HideLockedButton.textContent = "Hide Locked"; document.querySelector("#theme_boost-drawers-courseindex").childNodes[1].append(HideLockedButton); HideLockedButton.addEventListener("click", function() { let all_Locked = document.querySelector("#theme_boost-drawers-courseindex").querySelectorAll(".restrictions") all_Locked.forEach((Locked_Module)=>{ Locked_Module.style.setProperty("display", "none", "important"); }) HideLockedButton.textContent = "Locked are hidden"; HideLockedButton.disabled = true; }) } else if(node.href && node.href.includes('.pdf?forcedownload=1')){ node.href=node.href.replace('?forcedownload=1',"") node.target='_blank' } else if(node.href && node.href.includes(".PNG?forcedownload=1")){ let img = document.createElement("img") img.classList+="resourceimage" img.loading="lazy" img.src = node.href img.style.display = "none"; let Hide_IMG = document.createElement("button"); Hide_IMG.setAttribute("onclick",` console.log("Button clicked"); console.log("UwU"); var img = this.nextElementSibling; if (img.style.display != "none") { img.style.display = "none"; this.textContent = "Show Img"; } else { img.style.display = "block"; this.textContent = "Hide Img"; } `) Hide_IMG.style.border = "none" Hide_IMG.style.borderRadius = "5px" if(img.style.display != "none"){ Hide_IMG.textContent = "Hide Img"; } else{ Hide_IMG.textContent = "Show Img"; } node.parentElement.appendChild(Hide_IMG) node.parentElement.appendChild(img) Hide_IMG.onclick = function () { console.log("Button clicked"); console.log("UwU"); if (img.style.display != "none") { img.style.display = "none"; Hide_IMG.textContent = "Show Img"; } else { img.style.display = "block"; Hide_IMG.textContent = "Hide Img"; } "UwU"}; } } } } } }); observer_Courses.observe(document, { childList: true, subtree: true }); } //end IIFE })();