Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name LOR spoiler
- // @namespace linux.org.ru
- // @description Add spoiler functionality
- // @include https://linux.org.ru/*
- // @include https://www.linux.org.ru/*
- // @version 1
- // @grant none
- // ==/UserScript==
- $script.ready('jquery',function(){
- console.log('LOR spoiler is ON');
- // spoiler
- var cuts = $('[id ^= cut]');
- cuts.each(function(){
- if($(this).text().split("\n").length<=5) return; // allow small cut
- var cut_id = $(this).attr('id');
- $(this).hide();
- $(this)
- .before(
- '<span class="sign">'+
- '<span>>>> </span>'+
- '<a '+
- 'id="spoiler-'+ cut_id +'" '+
- 'href="javascript:void(0);" '+
- 'onClick="javascript:$(\'#'+ cut_id +'\').css(\'display\')==\'none\'?$(\'#'+ cut_id +'\').show():$(\'#'+ cut_id +'\').hide();">'+
- 'cut-spoiler'+
- '</a>'+
- '</span>'
- );
- });
- // code
- var code_id = 0;
- $('.code').each(function(){
- var no_hl = $(this).find('pre.no-highlight code');
- if(no_hl.length>0){
- if(no_hl.text().split("\n").length<=5) return; // allow small cut
- } else {
- if($(this).text().split("\n").length<=5) return; // allow small cut
- }
- $(this).attr('id','hide-code'+ code_id).hide();
- $(this)
- .before(
- '<span class="sign">'+
- '<span>>>> </span>'+
- '<a '+
- 'id="spoiler-hide-code'+ code_id +'" '+
- 'href="javascript:void(0);" '+
- 'onClick="javascript:$(\'#hide-code'+ code_id +'\').css(\'display\')==\'none\'?$(\'#hide-code'+ code_id +'\').show():$(\'#hide-code'+ code_id +'\').hide();">'+
- 'code-spoiler'+
- '</a>'+
- '</span>'
- );
- code_id+=1;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement