NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name мегаМозгСоХраброгоГика
// @description Убирает комментарии без оценки под спойлер (habrahabr,geektimes,sohabr,megamozg).
// @author код - winnz | идея, доработки -pepsioner
// @include http://*.geektimes.ru/*
// @match http://*.geektimes.ru/*
// @include https://*.geektimes.ru/*
// @match https://*.geektimes.ru/*
// @include http://*.habrahabr.ru/*
// @match http://*.habrahabr.ru/*
// @include https://*.habrahabr.ru/*
// @match https://*.habrahabr.ru/*
// @include http://*.sohabr.net/*
// @match http://*.sohabr.net/*
// @include https://*.sohabr.net/*
// @match https://*.sohabr.net/*
// @include http://*.megamozg.ru/*
// @match http://*.megamozg.ru/*
// @include https://*.megamozg.ru/*
// @match https://*.megamozg.ru/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @version 2.0
// @grant none
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
$(function() {
// Variables
var el = {
$comments: $( '#comments [id^="comment_"]' )
};
// Functions
function getScore( $el ) {
return $el.find( '.score' ).eq(0).html() >> 0
}
function createSpoiler( $el ) {
var $msg = $el.find( '.message' ).eq(0),
$header = $el.find( '.info' ).eq(0),
$spoiler = $( document.createElement( 'span' ) );
$spoiler.css({
'position': 'absolute',
'top': '0',
'right': '60px',
'width': '80px',
'height': '24px',
'line-height': '24px',
'font-weight': 'bold',
'cursor': 'pointer'
});
$spoiler.html( '[ SPOILER ]' );
$spoiler.appendTo( $header );
$spoiler.on( 'click', function() {
$msg.toggle();
});
$header.css( 'border-bottom', '1px solid #dedede' );
$msg.hide();
}
// Run
el.$comments.each(function() {
if (getScore($(this)) < 1) {
createSpoiler( $(this) );
}
});
});