Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Spoiler FC
- // @namespace Spoiler FC
- // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
- // @include http://www.forocoches.com*
- // @include https://www.forocoches.com*
- // @version 1
- // @grant none
- // ==/UserScript==
- $(".spoiler").prev().replaceWith("<button id=\"btn-spoiler\" class=\"smallfont\" style=\"font-weight:bold; margin-left:8px; margin-bottom:2px\">Mostrar spoiler</button>");
- $("button#btn-spoiler").click(function() {
- if ($(this).next().attr("class").contains("open-spoiler")) {
- $(this).text("Mostrar spoiler");
- $(this).next().removeClass("open-spoiler");
- } else {
- $(this).text("Ocultar spoiler");
- $(this).next().addClass("open-spoiler");
- }
- });
- function addGlobalStyle(css) {
- var head, style;
- head = document.getElementsByTagName('head')[0];
- if (!head) { return; }
- style = document.createElement('style');
- style.type = 'text/css';
- style.innerHTML = css;
- head.appendChild(style);
- }
- addGlobalStyle(' .spoiler { color: black; font-weight: bolder; background-color: #FAFCFF; width: auto; height: 0; max-height: null; text-align: left; border-radius: 6px; cursor: default; overflow: auto; margin: 5px 2px 2px; padding: 0px; border: 0px inset; } .open-spoiler { height: auto; margin-left: 8px; border-radius: 0; padding: 10px; }');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement