[Make DTF Great Again] Обновил скрипты

Добавление фильтра Всё в Свежее:

// ==UserScript== // @name DTF new/all // @description Replaces header and Fresh link to /new/all, adds menu item in a sorting filter // @updateURL https://v66701.hosted-by-vdsina.com:4212/script/dtf.new.js // @downloadURL https://v66701.hosted-by-vdsina.com:4212/script/dtf.new.js // @version 1.2.1 // @match https://dtf.ru/* // ==/UserScript== (() => { const NEW_URL = "/new/all"; function all__open() { location.href = NEW_URL; } async function sidebar__fix() { let links = document.querySelectorAll('a.sidebar-item[href="/new"], div.header__left > a[href="/"], a.tabs__tab[href="/new"]'); links.forEach(link => { link.addEventListener("click", all__open); }) } function selector_element__add() { let menu = document.getElementsByClassName('context-list-option'); if (menu.length > 0) { var old = menu[0].cloneNode(true); menu[0].setAttribute('href', '/new/all'); menu[0].textContent = 'Всё'; menu[0].replaceWith(menu[0].cloneNode(true)); if (window.location.pathname === NEW_URL) menu[0].classList.add("context-list-option--selected"); else menu[0].classList.remove("context-list-option--selected"); menu[0].classList.add("selector-item-new-all"); menu[0].setAttribute('data-gtm-click', ["New Feed — Sort — All"]); menu[0].after(old); } } async function selector_element__remove() { let menu = document.getElementsByClassName("selector-item-new-all"); if (menu.length > 0) menu[0].parentNode.removeChild(menu[0]); } async function selector__fix() { let selector = document.querySelectorAll('div[data-gtm-click="[\\"Popular Feed — Sort\\"]"], div[data-gtm-click="[\\"My Feed — Sort\\"]"]'); if (selector.length > 0) selector[0].addEventListener("click", selector_element__remove); let selectorNew = document.querySelectorAll('div[data-gtm-click="[\\"New Feed — Sort\\"]"]') if (selectorNew.length > 0) selectorNew[0].addEventListener("click", selector_element__add); let button = document.querySelectorAll('div[data-gtm-click="[\\"New Feed — Sort\\"]"] > button.dropdown__label'); if (button.length > 0 && button[0].childNodes[0].textContent === " ") button[0].childNodes[0].textContent = 'Всё'; } async function main() { await sidebar__fix(); await selector__fix(); } window.addEventListener('DOMContentLoaded', async () => { await main(); }) let html_tag_observer = new MutationObserver(async (mutationRecords) => { html_tag_observer.disconnect(); await main(); html_tag_observer__start(); }); html_tag_observer__start(); function html_tag_observer__start() { html_tag_observer.observe(document.querySelector(`html`), { attributes: true, childList: true, subtree: true, characterData: false }); } })();
1717

Спасибо!

3
Ответить