NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Just-magic count words // @namespace derevnia // @author vk.com/derevnia // @description Подсчитывает количество слов разных цветов // @version 0.8 // @include *://just-magic.org/dmn/put_task.php* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js // @updateURL https://openuserjs.org/install/derevnia/Just-magic_count_words.user.js // @downloadURL https://openuserjs.org/install/derevnia/Just-magic_count_words.user.js // @grant none // ==/UserScript== window.onload = function () { document.getElementsByClassName("col-lg-10")[0] .innerHTML += "<br /><br /><div style='display:inline;padding:0 10px;font-weight:bold;color:#D42A00'>Красных: <div id='red_words' style='display:inline;color:#45688e;'>количество</div> - <div id='red_words_percent' style='display:inline;color:#45688e;'></div>%</div><br /><div style='display:inline;padding:0 10px;font-weight:bold;color:#778700'>Зелёных: <div id='green_words' style='display:inline;color:#45688e;'>количество</div> - <div id='green_words_percent' style='display:inline;color:#45688e;'></div>%</div><br /><input id='percent' type='number' step='0.01' pattern='[0-9.]' max='1.01' min='0' style='color: red;margin: 11px 11px 0;'>"; var variable_percent = 0.31; document.getElementById('percent').value = variable_percent; function recount_words(){ var recount = document.getElementById('percent').value; if (recount !=='') { variable_percent = document.getElementById('percent').value; } var r=0; var g=0; $(".ibox-content span").each(function(){ if ($(this).attr("title")){ var li = $(this).attr("title").split('(')[1]; li = li.split(')')[0].replace(/[^0-9E_#-. ]/g, ""); if (li.toLocaleString() < parseFloat(variable_percent)){ r++; $(this).css("text-decoration", "underline"); }else{ g++; $(this).css("text-decoration", "none"); } } }); $("#red_words").text(r); $("#green_words").text(g); var recount_red = (r*100)/(r+g); recount_red = recount_red.toFixed(1); var recount_green = (g*100)/(r+g); recount_green = recount_green.toFixed(1); $("#red_words_percent").text(recount_red); $("#green_words_percent").text(recount_green); } recount_words(); document.getElementById('percent').addEventListener('change', recount_words, false); document.getElementById('percent').addEventListener('mousewheel', recount_words, false); document.getElementById('percent').addEventListener('keyup', recount_words, false); };