Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Discordomet v2
- // @namespace http://tabun.everypony.ru
- // @description ДИСКОРДОМЕТ ПЫЩЩЬ ПЫЩЩЬ ПОПЯЧСА ОЛОЛО
- // @include http://tabun.everypony.ru/blog/*
- // @require http://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js
- // ==/UserScript==
- var mode = "single";
- function switchMode()
- {
- if(mode == "single")
- {
- mode = "all";
- $("#discordModeBtn").text("A");
- }
- else
- {
- mode = "single";
- $("#discordModeBtn").text("S");
- }
- }
- function collectVoteFunctionPairs(onlyOne)
- {
- var voteFunctionPairs = [];
- var arrowContainers = $(".vote");
- var inacceptableClasses = [ "voted", "guest", "vote-expired" ];
- for(var i = 0; i < arrowContainers.length; i++)
- {
- var votable = true;
- for(var j = 0; j < inacceptableClasses.length; j++)
- {
- if($(arrowContainers[i]).hasClass(inacceptableClasses[j]))
- {
- votable = false;
- break;
- }
- }
- if(votable)
- {
- voteFunctionPairs.push({
- "voteUpFunc" : new Function($(arrowContainers[i]).find(".vote-up").attr("onclick")),
- "voteDownFunc" : new Function($(arrowContainers[i]).find(".vote-down").attr("onclick"))
- });
- if(onlyOne)
- {
- break;
- }
- }
- }
- return voteFunctionPairs;
- }
- function vote(voteMode)
- {
- var voteFunctionPairs = collectVoteFunctionPairs(mode == "single");
- if(voteFunctionPairs.length == 0)
- {
- alert("There's no work for Discord.");
- }
- for(var i = 0; i < voteFunctionPairs.length; i++)
- {
- switch(voteMode)
- {
- case 1:
- voteFunctionPairs[i]["voteUpFunc"]();
- break;
- case 2:
- voteFunctionPairs[i]["voteDownFunc"]();
- break;
- case 3:
- if(Math.random() > 0.5)
- {
- voteFunctionPairs[i]["voteUpFunc"]();
- }
- else
- {
- voteFunctionPairs[i]["voteDownFunc"]();
- }
- break;
- }
- }
- }
- if(new RegExp("[0-9]+.html").test(document.URL))
- {
- var updateBar = $("#update");
- var discordMenu = updateBar.clone();
- discordMenu.css("bottom", 200);
- discordMenu.html("");
- updateBar.before(discordMenu);
- var buttons = [
- { "id" : "discordUpvoteBtn", "symbol" : "+", "color" : "green", "onClick" : function(){ vote(1); } },
- { "id" : "discordDownvoteBtn", "symbol" : "—", "color" : "red", "onClick" : function(){ vote(2); } },
- { "id" : "discordRandomvoteBtn", "symbol" : "?", "color" : "blue", "onClick" : function(){ vote(3); } },
- { "id" : "discordModeBtn", "symbol" : "S", "color" : "#FF0080", "onClick" : switchMode }
- ];
- var buttonSize = 25;
- var discordFontSize = 14;
- for(var i = 0; i < buttons.length; i++)
- {
- discordMenu.html(discordMenu.html() + "<button id='" + buttons[i]["id"] + "'>" + buttons[i]["symbol"] + "</button><br>");
- }
- for(var i = 0; i < buttons.length; i++)
- {
- $("#" + buttons[i]["id"]).css({
- "width" : buttonSize,
- "height" : buttonSize,
- "background-color" : "transparent",
- "font-size" : discordFontSize,
- "color" : buttons[i]["color"],
- "border" : 0,
- "font-weight" : "bold"
- }).attr('onclick', '').click(buttons[i]["onClick"]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment