auto moodle correct display

correct the css problems in moodle based site wen you autorect tests.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         auto moodle correct display
// @namespace    http://www.gann.be/
// @version      0.6.2
// @description  correct the css problems in moodle based site wen you autorect tests.
// @author       Morgan Schaefer www.gann.be
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';


function getMeta(metaName) {
   const metas = document.getElementsByTagName('meta');

   for (let i = 0; i < metas.length; i++) {
      if (metas[i].getAttribute('name') === metaName) {
         return metas[i].getAttribute('content');
      }
   }

   return '';
}

let keywords = getMeta('keywords');
let isItMoodle = keywords.search("moodle");
let tableauDeBord = keywords.search("Tableau de bord");
let acceuil = keywords.search("Campus Virtuel IEPS Fléron: Se connecter sur le site");

if((isItMoodle >= 0)&&(tableauDeBord<0)&&(acceuil<0)){
   console.log("this is a moodle based website");
   function addGlobalStyle(css) {
      var head, style;
      head = document.getElementsByTagName('head')[0];
      if (!head) { return; }
      style = document.createElement('style');
      style.type = 'text/css';
      style.innerHTML = css;
      head.appendChild(style);
   }
   addGlobalStyle('.jsenabled .collapsibleregion{ overflow: visible !important; }');
   addGlobalStyle('.container-fluid{ width: auto !important; }');
   addGlobalStyle('@media (min-width: 768px) .col-md-9 {  max-width: 100% !important;}');
   addGlobalStyle('.text-nowrap { white-space: normal !important;}');

} else{
   console.log("this is not a moodle based website or it is an exlued page");

}
})();