seeSpoilerJol

Affichage en un clic de tous les spoilers de la page

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        seeSpoilerJol
// @namespace   jolBoost
// @description Affichage en un clic de tous les spoilers de la page
// @include     http://forums.jeuxonline.info/showthread.php*
// @version     0.1.3
// @grant       none
// ==/UserScript==
//Recup element ou placer le nouveau bouton
var previousElt = document.getElementById('intraforums1_menu');
var div = document.createElement('DIV');
div.style.marginBottom = '5px';
div.style.textAlign = 'right';
//Bouton
var clickButton = document.createElement('BUTTON');
clickButton.className = 'button show';
clickButton.onclick = showAllSpoiler;
clickButton.id = 'allSpoilButton';
var textButton = document.createTextNode('Afficher tous les spoilers');
clickButton.appendChild(textButton);
div.appendChild(clickButton);
//Texte explicatif
var br = document.createElement('BR');
var smallElt = document.createElement('SMALL');
var emElt = document.createElement('EM');
var explainTxt = document.createTextNode('Cliquez sur le bouton pour afficher tous les contenus en Spoiler dans la page');
emElt.appendChild(explainTxt);
smallElt.appendChild(emElt);
div.appendChild(br);
div.appendChild(smallElt);
//Et on ajoute le tout ! 
previousElt.parentNode.insertBefore(div, previousElt.nextSibling);
/** Fonction d'affichage du spoiler **/
function showAllSpoiler() {
    var show = false;
    var button = document.getElementById('allSpoilButton');
    if (button.className == 'button show') {
        show = true;
    }
    var elements = document.getElementsByClassName('spoiler');
    for (var i = 0, l = elements.length; i < l; i++) {
        if (show) {
            elements[i].className = elements[i].className + ' spoiler-selected';
        } else {
            elements[i].className = 'spoiler';
        }
    }
    while (button.firstChild) {
        button.removeChild(button.firstChild);
    }
    if (show) {
        var newtextButton = document.createTextNode('Cacher');
        button.appendChild(newtextButton);
        button.className = 'button hide';
    } else {
        var newtextButton = document.createTextNode('Afficher tous les spoilers');
        button.appendChild(newtextButton);
        button.className = 'button show';
    }
}