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

Главное: добавил автоматическое обновление (кнопкой из Tampermonkey/Userscripts). Но в первый раз надо скопировать их руками (собственно, ради чего этот пост).

Как добавить скрипт в браузер: тык

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

// ==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 }); } })();

Кнопка кэшера имён в профиле:

// ==UserScript== // @name DTF names // @description Show previous usernames // @updateURL https://v66701.hosted-by-vdsina.com:4212/script/dtf.names.js // @downloadURL https://v66701.hosted-by-vdsina.com:4212/script/dtf.names.js // @version 1.1.1 // @match https://dtf.ru/* // ==/UserScript== (() => { const CACHER_HOST = "https://v66701.hosted-by-vdsina.com:4212/" function button__add() { if (window.location.href.split('/u/')[1] === undefined) return if (document.getElementsByClassName("names-button").length > 0) return let buttons = document.getElementsByClassName("button button--size-m button--type-minimal button--icon-only") if (buttons.length < 1) return let old_button = buttons[buttons.length - 1] let new_button = old_button.cloneNode(true) old_button.after(new_button) new_button.classList.add("names-button") new_button.childNodes[0].childNodes[0].setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#my_feed') new_button.addEventListener("click", names__show) } async function names__show() { let users let user_id = window.location.href.split('/u/')[1].split('-')[0] const response = await fetch(CACHER_HOST + user_id, { method: 'get' }) await response.text().then(text => { users = JSON.parse(text) }) let text = users.length > 0 ? users.join('\n') : "В базе нет имён этого пользователя" alert(text) } async function main() { await button__add() } 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
1 комментарий

Спасибо!

3
Ответить