Stack Overflow : liste flottante de saut entre réponses
Ajoute une liste flottante de toutes les réponses avec leur score pour sauter à chacune en un clic.
Code à copier
/* Floating list of answers to jump between them */
(function () {
if (document.getElementById('sof-answer-toc')) return;
var answers = document.querySelectorAll('#answers .answer');
if (answers.length < 2) return;
var box = document.createElement('div');
box.id = 'sof-answer-toc';
box.style.cssText = 'position:fixed;right:10px;bottom:10px;background:#fff;border:1px solid #ccc;border-radius:6px;padding:6px;font-size:12px;z-index:9999;box-shadow:0 2px 8px rgba(0,0,0,0.2);';
answers.forEach(function (a, i) {
var score = a.querySelector('.js-vote-count');
var link = document.createElement('a');
link.textContent = 'Answer ' + (i + 1) + (score ? ' (' + score.textContent.trim() + ')' : '');
link.style.cssText = 'display:block;padding:2px 6px;cursor:pointer;color:#0074cc;';
link.addEventListener('click', function () {
a.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
box.appendChild(link);
});
document.body.appendChild(box);
})();
Comment utiliser cet exemple
- Copiez le code avec le bouton ci-dessus.
- Installez JustZix (2 minutes) et ouvrez l'extension sur la page cible.
- Ajoutez une nouvelle règle correspondant à cette page.
- Activez le panneau d'actions, ajoutez un bouton dans l'onglet Actions et collez-y le code — lancez-le en un clic.
Notez cet exemple
Aucune note — soyez le premier.