colddegree / fefu idm schedule group auto picker

// ==UserScript==
// @name         fefu idm schedule group auto picker
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  тупа выбирает группу, шоб постоянно не искать
// @author       me
// @match        https://idm.dvfu.ru/component/calendar/calendar*
// @grant        none
// @license MIT
// @copyright 2018, colddegree (https://openuserjs.org//users/colddegree)
// ==/UserScript==

(function() {
    'use strict';

    const GROUP_NAME = "Б8304";

    (function changeGroup(groupName) {
        setGroup(groupName);
        setGroupLabel(groupName);
    })(GROUP_NAME);

    function setGroup(groupName) {
        let groupSelect = document.getElementById("filtergroups");
        let indexOfGroup = 0;

        for (let i = 0; i < groupSelect.options.length; i++) {
            if (groupSelect.options[i].text == groupName) {
                indexOfGroup = i;
                break;
            }
        }

        groupSelect.selectedIndex = indexOfGroup;
        groupSelect.onchange();
    }

    function setGroupLabel(groupName) {
        let label = document.querySelector("#filtergroups_chosen > a.chosen-single");
        label.classList.remove("chosen-default");
        label.querySelector("span").textContent = groupName;
    }
})();