Top.Mail.Ru
Ответы

TopicTracker v1.0. Описание см. в обсуждении

12345678910111213141516171819202122232425262728293031323334353637383940
// ==UserScript==
// @name         TopicTracker
// @namespace    https://example.com/
// @version      1.0
// @description  Список вопросов с ником, временем, аватаром и переключателем темы
// @match        https://otvet.mail.ru/*
// @grant        none
// ==/UserScript==
(function(){
'use strict';
const id='custom-question-box',key='question_theme';let theme=localStorage.getItem(key)||'light';
function makeUI(){let b=document.getElementById(id);if(b)return b;b=document.createElement('div');b.id=id;b.style.cssText='position:fixed;top:50px;right:10px;width:400px;max-height:90vh;overflow-y:auto;background:white;border:1px solid black;padding:0;z-index:9999;font-family:sans-serif;font-size:14px;box-shadow:0 0 10px rgba(0,0,0,0.3);transition:background 0.3s ease,border-color 0.3s ease;';
const h=document.createElement('div');h.style.cssText='position:sticky;top:0;background:#eee;padding:5px 10px;display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #ccc;font-weight:bold;z-index:10;';
const t=document.createElement('span');t.id='custom-question-box-title';h.appendChild(t);b.header=h;
const c=document.createElement('div');c.style.cssText='display:flex;gap:5px;align-items:center;';
function btn(txt,tip,cb){const x=document.createElement('button');x.textContent=txt;x.title=tip;x.style.cssText='width:24px;height:24px;padding:0;border:none;background:#ccc;cursor:pointer;border-radius:3px;font-size:12px;font-weight:bold;user-select:none;';x.onclick=cb;return x}
const def={width:'400px',height:'',top:'50px',right:'10px'};
c.appendChild(btn('⟳','Обновить',refresh));
c.appendChild(btn('X','Закрыть',()=>b.remove()));
c.appendChild(btn('-','Свернуть',()=>{b.style.height='30px';b.style.overflow='hidden'}));
c.appendChild(btn('R','Сбросить',()=>{b.style.width=def.width;b.style.height=def.height;b.style.top=def.top;b.style.right=def.right;b.style.overflow='auto'}));
c.appendChild(btn('+','Развернуть',()=>{b.style.top='0';b.style.right='0';b.style.width='calc(100vw - 20px)';b.style.height='100vh';b.style.overflow='auto'}));
c.appendChild(btn('Т','Тема',()=>toggleTheme(b)));
h.appendChild(c);b.appendChild(h);document.body.appendChild(b);return b}

function findTime(l){let e=l;for(let i=0;i<5;i++){e=e.parentElement;if(!e)break;const t=e.querySelector('._text_1o2qj_1');if(t)return t.textContent.trim()}return'—'}
function findUser(l){let e=l;for(let i=0;i<5;i++){e=e.parentElement;if(!e)break;const p=e.querySelector('a[href^="/profile/"]');if(p){const m=p.href.match(/\/profile\/([^\/\?]+)/);if(m&&m[1]){const i=e.querySelector('a._ImageBase_w8ijr_1 img');return{nickname:m[1],avatar:i?i.src:null}}}}return null}

function process(){const b=document.getElementById(id);if(!b)return;const q=Array.from(document.querySelectorAll('a[href^="/question/"]:not([data-processed])')).filter(l=>!l.classList.contains('_noUnderline_1xeik_9'));
q.forEach(l=>{const u=findUser(l);l.setAttribute('data-processed','1');if(!u)return;const href=l.href,title=l.textContent.trim(),time=findTime(l),e=document.createElement('div');e.style.cssText='margin-bottom:10px;word-break:break-word;display:flex;align-items:center;gap:8px;';let a='';if(u.avatar)a=`<img src="${u.avatar}" alt="Аватар" style="width:32px;height:32px;border-radius:50%;object-fit:cover;">`;e.innerHTML=`${a}<div><b>${u.nickname}</b> [${time}]: <a href="${href}" target="_blank" rel="noopener">${title}</a></div>`;b.appendChild(e)});applyTheme(b,theme)}

function refresh(){const b=makeUI(),p=location.pathname.replace(/^\/+/,'');const t=document.getElementById('custom-question-box-title');if(t)t.textContent=p;while(b.children.length>1)b.removeChild(b.lastChild);document.querySelectorAll('a[href^="/question/"][data-processed]').forEach(l=>l.removeAttribute('data-processed'));process()}

function applyTheme(b,t){if(!b)return;if(t==='dark'){b.style.background='#000';b.style.borderColor='#666';b.style.color='#fff';if(b.header){b.header.style.background='#222';b.header.style.borderBottomColor='#444';b.header.style.color='#fff'}b.querySelectorAll('a').forEach(a=>{a.style.color='#80c0ff';a.style.textDecoration='none'})}else{b.style.background='#fff';b.style.borderColor='#ccc';b.style.color='#000';if(b.header){b.header.style.background='#eee';b.header.style.borderBottomColor='#ccc';b.header.style.color='#000'}b.querySelectorAll('a').forEach(a=>{a.style.filter='none';a.style.color='#0645ad';a.style.textDecoration='none'})}localStorage.setItem(key,t);theme=t}
function toggleTheme(b){applyTheme(b,theme==='light'?'dark':'light')}

function init(){if(location.pathname.includes('/question/'))return;refresh();new MutationObserver(()=>process()).observe(document.body,{childList:true,subtree:true})}
if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init)}else{init()}
})();

Код поджал чтоб влезло.

По дате
По рейтингу
Аватар пользователя
Оракул
1мес

Скрипт то ничего. а аккаунты не уводит?

Аватар пользователя
Мыслитель
1мес

А есть разница в какую скриптожевалку его засовывать? Вы там какую то предлагали, а у меня orangemonkey имеется, подойдет?

Аватар пользователя
Мудрец
1мес

как его включить

Аватар пользователя
Оракул
1мес

на андроид как сделать?

Аватар пользователя
Оракул
1мес

Спс. А на андроиде можно менять интерфейс?