js-tampermonkey-public-scripts/Убрать 3-ий блок новостей в просмотре писем.user.js
Unkas Amanjolov 42b29defae first commit
2024-10-07 10:25:50 +05:00

67 lines
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ==UserScript==
// @name Убрать 3-ий блок новостей в просмотре писем
// @namespace https://github.com/le91
// @version 1.0.1
// @description try to take over the world!
// @author You
// @match https://e.mail.ru/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=mail.ru
// @grant none
// ==/UserScript==
(function() {
'use strict';
function startRemove(){
var main = document.querySelector("#app-canvas > div > div.application-mail > div.application-mail__overlay > div > div.application-mail__layout.application-mail__layout_main > span")
main.children[2].remove();
console.log('блок уже удален первый эпат')
// Находим элемент
const targetElement = document.querySelector(".ReactVirtualized__Grid__innerScrollContainer");
// Получаем все div элементы внутри него
const divElements = targetElement.querySelectorAll('div');
let firstDivHeight = '';
// Проходимся по каждому div элементу
divElements.forEach(divElement => {
// Проверяем, если у div элемента высота больше 0px
if (divElement.style.height && parseInt(divElement.style.height) > 0) {
if (firstDivHeight === '') {
firstDivHeight = divElement.style.height;
}
// Удаляем все div элементы до данного элемента
let previousElement = divElement.previousElementSibling;
while (previousElement && previousElement.tagName === 'DIV' && firstDivHeight != '') {
const toRemove = previousElement;
previousElement = previousElement.previousElementSibling;
// toRemove.remove();
var cssStyle = document.querySelector(".ReactVirtualized__Grid__innerScrollContainer").getAttribute("style")
cssStyle = cssStyle + "margin-top: -"+firstDivHeight+";"
document.querySelector(".ReactVirtualized__Grid__innerScrollContainer").setAttribute("style",cssStyle)
}
// Выходим из цикла после удаления
return;
}
});
}
// удалить новости с правой части экрана
setTimeout(function() {
try {
startRemove()
} catch { console.log('блок уже удален первый эпат') }
}, 3000);
setTimeout(function() {
try {
startRemove()
} catch { console.log('блок уже удален второй эпат') }
}, 13000);
})();