Advertisement
MrProperESP

Untitled

Apr 13th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Spoiler FC
  3. // @namespace Spoiler FC
  4. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  5. // @include http://www.forocoches.com*
  6. // @include https://www.forocoches.com*
  7. // @version 1
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. $(".spoiler").prev().replaceWith("<button id=\"btn-spoiler\" class=\"smallfont\" style=\"font-weight:bold; margin-left:8px; margin-bottom:2px\">Mostrar spoiler</button>");
  12.  
  13.  
  14. $("button#btn-spoiler").click(function() {
  15. if ($(this).next().attr("class").contains("open-spoiler")) {
  16. $(this).text("Mostrar spoiler");
  17. $(this).next().removeClass("open-spoiler");
  18. } else {
  19. $(this).text("Ocultar spoiler");
  20. $(this).next().addClass("open-spoiler");
  21. }
  22. });
  23.  
  24. function addGlobalStyle(css) {
  25. var head, style;
  26. head = document.getElementsByTagName('head')[0];
  27. if (!head) { return; }
  28. style = document.createElement('style');
  29. style.type = 'text/css';
  30. style.innerHTML = css;
  31. head.appendChild(style);
  32. }
  33.  
  34. 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