Esfera

try to take over the world!

当前为 2021-12-07 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Esfera
// @namespace    Esfera-CarlesV
// @version      0.1
// @description  try to take over the world!
// @author       CarlesV
// @match        https://bfgh.aplicacions.ensenyament.gencat.cat/bfgh/avaluacio/parcialAvaluacioGrupAlumne/*
// @require      http://code.jquery.com/jquery-latest.js
// @icon         https://www.google.com/s2/favicons?domain=gencat.cat
// @grant        none
// ==/UserScript==

/*
LI;AS
EN;AN
*/

function sleep(milliseconds) {
  const date = Date.now();
  let currentDate = null;
  do {
    currentDate = Date.now();
  } while (currentDate - date < milliseconds);
}

function trimChar(string, charToRemove) {
    while(string.charAt(0)==charToRemove) {
        string = string.substring(1);
    }

    while(string.charAt(string.length-1)==charToRemove) {
        string = string.substring(0,string.length-1);
    }

    return string;
}

var i=0;

function fer_notes()
{
    var text_notes = $('#notes').val();

    const regex = /(.*)\t(.*)\t(("[^"]*")|(.*))/gm;

    let m;
    var pos=0;
    //var res=new Array();

    var matches = text_notes.match(regex);

    var x=i;
    {
        var lin=matches[x].split("\t");
        console.log(lin[0] + " " + lin[1]);

        $("div.ng-binding:contains('" + lin[0] + "')").parent().find(".form-control.ng-pristine").val("string:"+lin[1]);

        $("div.ng-binding:contains('" + lin[0] + "')").parent().find("a")[1].click();

        var com = trimChar(lin[2],'"');

        $("textarea.ng-pristine").val(com);
        //$("textarea.ng-pristine").parent().parent().find("a")[1].click();
    }
    i++;
}

(function() {
    'use strict';

    // Your code here...
    setTimeout(
        function()
        {
            $(window).on('hashchange', function(e){
                if (window.location.href.search("parcialAvaluacioGrupAlumneEntradaDades")==-1)
                    $("#carles").hide();
                else
                    $("#carles").show();
                $("#notes").val("");
            });

            $(document).on('click', '#fer_notes', function() {
                fer_notes();
            });
            $(".col-sm-12.main-view.ng-scope").before(`
<div class='row' id='carles'>
  <div class='col-sm-6'>
    <textarea style='width:100%;' spellcheck='false' rows='10' id='notes'></textarea>
  </div>
  <div class='col-sm-6'>
  Esfera Tutors 0.1 - Carles [email protected]
  <BR>Instruccions:
  <ul><li>Copia del google shhets les 3 columnes: Codi materia, Nota, i comentari.
  <li>Pega al quadre del costat.
  <li>Apreta el boto fer, revisa comentari i desa.
  <li>Torna a apreta el boto fer (fins acabar tots els àmbils).
  </ul>
  <button id='fer_notes'>Fer</button>
  </div>
</div>`);
                if (window.location.href.search("parcialAvaluacioGrupAlumneEntradaDades")==-1)
                    $("#carles").hide();
                else
                    $("#carles").show();
        }, 1000);
})();