Greasy Fork

Greasy Fork is available in English.

东软智慧教育平台优化&去广告

Combine styles and element blocking on Neuedu personHome page

// ==UserScript==
// @name         东软智慧教育平台优化&去广告
// @namespace    neuedupukgaai
// @version      0.31
// @description  Combine styles and element blocking on Neuedu personHome page
// @author       nm
// @match        http://study.neuedu.com/
// @match        http://study.neuedu.com/personHome
// @match        http://study.neuedu.com/loginF
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Add flex-wrap style to swiper-wrapper class within neu-teacher-main
    var styleSwiper = document.createElement('style');
    styleSwiper.type = 'text/css';
    styleSwiper.innerHTML = '.neu-teacher-main .swiper-wrapper { flex-wrap: wrap !important; }';
    document.getElementsByTagName('head')[0].appendChild(styleSwiper);

    // Hide the swiper-button-next element within neu-teacher-main
    var styleButtonNext = document.createElement('style');
    styleButtonNext.type = 'text/css';
    styleButtonNext.innerHTML = '.neu-teacher-main .swiper-button-next { display: none !important; }';
    document.getElementsByTagName('head')[0].appendChild(styleButtonNext);

    // Function to remove an element from the page
    function removeElement(selector) {
        var element = document.querySelector(selector);
        if (element) {
            element.parentNode.removeChild(element);
        }
    }

    // Block pointermove event
    document.addEventListener('pointermove', function(event) {
        event.stopPropagation();
        event.preventDefault();
    }, true);

    // Observe for changes and remove elements if they are added again
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.addedNodes && mutation.addedNodes.length > 0) {
                // Element added to DOM
                var potentialButtons = document.querySelectorAll('button.msg-confirm-btn');
                if (potentialButtons.length > 0) {
                    var reloginButton = potentialButtons[0];
                    if (reloginButton.innerText.includes('重新登录')) {
                        reloginButton.click();
                    }
                }
                // Remove specified elements
                removeElement('#mask');
                removeElement('div.warp > div.main-content:nth-child(2) > div.banner-mods:first-child');
                removeElement('div.warp > div.main-content:nth-child(2) > div.container:nth-child(2) > div.mods:last-child > div.el-row:first-child');
                removeElement('div.warp > div.main-content:nth-child(2) > div.banner-mods-stu:first-child');
                removeElement('div.warp > div.main-content:nth-child(2) > div.container:nth-child(2) > div.apps:first-child');
                //removeElement('div.container > div.apps');
            }
        });
    });

    var config = { attributes: false, childList: true, subtree: true };
    observer.observe(document.body, config);
})();