Меняем в браузере Свежее на Всё
Заменяет ссылку в логотипе и в левом меню на /new/all
// ==UserScript==
// @name DTF new/all
// @description Replace header and Fresh link to /new/all
// @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.0
// @match https://dtf.ru/*
// ==/UserScript==
(() => {
async function sidebar__fix() {
let links = document.querySelectorAll('a[href="/new"], a[href="/"]');
links.forEach((elem) => {
elem.setAttribute('href', '/new/all');
elem.classList.remove('sidebar-item--active');
elem.replaceWith(elem.cloneNode(true));
})
}
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));
menu[0].classList.remove("context-list-option--selected");
menu[0].setAttribute('data-gtm-click', ["New Feed — Sort — All"]);
menu[0].after(old);
}
}
async function selector__fix() {
if (window.location.href.startsWith("https://dtf.ru/new")) {
let selector = document.getElementsByClassName('feed-sorting')
if (selector.length > 0)
selector[0].addEventListener("click", selector_element__add);
}
if (window.location.href === "https://dtf.ru/new/all") {
let button = document.getElementsByClassName('dropdown__label');
if (button.length > 0)
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
});
}
})();
Хуйня. Лучше накатать парсер, чтобы только топ срачи отображались, а то заебало тратить время впустую в поисках.