EnchancedPool

Dodatek dodaje podgląd wyników bez konieczności klikania czegokolwiek.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        EnchancedPool
// @namespace   AnkietoRozbudowywacz
// @include     http://www.wykop.pl/*
// @version     1.2
// @grant       none
// @description  Dodatek dodaje podgląd wyników bez konieczności klikania czegokolwiek.
// ==/UserScript==

function AnkietoRozbudowywacz()
{
  $('#surveyBox').each(function () {
    var arr = [
    ];
    $('ul[data-surveyresult] li').each(function () {
      arr.push({
        text: $(this).children('div:first-child').text(),
        width: getPercentage($(this).find('div div').attr('style'), 'width')
      });
    });
    $('ul[data-surveyform] li').each(function (i) {
      var background = prefixed('background', 'linear-gradient(left, rgba(67,131,175,.25) ' + arr[i].width + '%, white 0%);');
      $(this).append('<div class="js-rozbudowywacz" style=\'width:20%; float: right; clear:both; padding: 2px; ' + background + '\'>' + arr[i].text + '</div>');
    });
  });
}
AnkietoRozbudowywacz();
$(document).on('ajaxSuccess', function (event, request, settings) {
  if (request.responseJSON.operations[0].method === 'handleAjaxPagination')
  {
    $('.js-rozbudowywacz').each(function () {
      $(this).remove();
    });
    AnkietoRozbudowywacz();
  }
});

function prefixed(key, value) {
 return [
   key + ': -webkit-' + value,
   key + ': -moz-' + value,
   key + ': -ms-' + value,
   key + ': ' + value
  ].join(' ');
}

function getPercentage(style, key) {
 var match = style.match(new RegExp(key + ':\\s*(\\d+(\\.\\d*)?)%'));
 return match ? parseFloat(match[1], 10) : 0;
}