Author

Topic: Poloniex convenience modifications (Read 1139 times)

newbie
Activity: 14
Merit: 0
September 09, 2014, 02:28:16 PM
#4
but what does it do? what are its features

trollbox filter is nice


mostly that. adding buttons next to people names, storing inside a cookie who made it on the lesser noisy trolls list. I mute people.
a feature often requested from the website, but never arrived. now done client-side.
(no update today, need more testing using this myself)
Update works like a charm  Smiley storing names inside PoloPreferences cookie.

second is VIP list, and looking for where to store data. On the long, a cookie is small space of some 4Kb. Perhaps I should transform names into numbers using a hash function, and use that for comparison. Or at least clipping to first 12 chars.
member
Activity: 106
Merit: 10
yes, sometimes I'm a cynical SOB
September 09, 2014, 12:12:56 PM
#3
but what does it do? what are its features

trollbox filter is nice
newbie
Activity: 14
Merit: 0
September 09, 2014, 11:03:14 AM
#2
reserved
newbie
Activity: 14
Merit: 0
September 09, 2014, 10:51:37 AM
#1
a convenience modification fitting onto Poloniex trading page

to install, you have to fit these requirements:

  • install Greasemonkey or something similar suiting your platform
  • read the code, cut&paste into a desktop file like poloniex.user.js
    (it is NOT advised to blindly install stuff like that since it can do literally anything to your trading portfolio)
  • click your browser on that, and enjoy
  • tip the author

Update: using icons next to usernames to add/remove them on the list

Quote
Angry : Please, do YOUR part to keep the TROLLBOX free of SPAM. Remember, only YOU can prevent Trollbox SPAM. Thank you. A message from your local MOD SQUAD
Hey! I'm on it Cheesy

Quote
Undecided : Is it possible to hide FORVER the Depth Chart
short answer: yes!

Quote
Cool: is there a way like on IRC to ignore people here? thx!
this plugin does it.

Code:
// ==UserScript==
// http://wiki.greasespot.net/Metadata_Block
//
// @name           Poloniex preferences
// @namespace      http://www.poloniex.com
// @description    adjust some preferences for ballances, chart graphs, Trollbox
// @version        0.1.2
// @date           2014-09-08
// @include        http*://www.poloniex.com/*
// @grant          none
// @run-at         document-end
// ==/UserScript==

//
// I got weary of always clicking the same buttons before doing sales,
// so greased up some things. All action happens at the bottom of this
// script, but before we begin need to setup some helper procedures.
// And some preferences.
//

// some people are special
//
window.mutelist = []; //handled by cookie store now, click the icon next to users to en/delist them here
//
window.VIPlist = ["your", "buddies", "here"]; //this still has to be done manually
//
// feeling gratious? send some to
// BTC 12RfcMPgJWmV2kxfL3mT22DPbLCoJWdFbB
// LTC LeKzdb8DZiwZUvDnT53uDuvSid3fXa4bMc


//~ http://www.w3schools.com/js/js_cookies.asp
function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
    }
    return "";
}

//http://www.shawnolson.net/a/503/altering-css-class-attributes-with-javascript.html
function changecss(theClass,element,value){   
    var cssRules;
    for (var S = 0; S < document.styleSheets.length; S++){
        try{
            document.styleSheets[S].insertRule(theClass+' { '+element+': '+value+'; }',document.styleSheets[S][cssRules].length);
        } catch(err){
        try{
            document.styleSheets[S].addRule(theClass,element+': '+value+';');
        } catch(err){
        try{
            if (document.styleSheets[S]['rules']) {
                cssRules = 'rules';
            } else if (document.styleSheets[S]['cssRules']) {
                cssRules = 'cssRules';
            } else {
                //no rules found... browser unknown
            }
            for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
               if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
                  if(document.styleSheets[S][cssRules][R].style[element]){
                     document.styleSheets[S][cssRules][R].style[element] = value;
                     break;
                  }
               }
            }
        } catch (err){}
        }
        }
    }
}

window.muteOnClick = function(someone){
    var index = window.mutelist.indexOf(someone.substr(0,16));
    if(index >= 0){
        window.mutelist.splice(index, 1);
        alert(someone + " is not muted");
    }
    else{
        window.mutelist.push(someone.substr(0,16));
        alert(someone + " is now on mute");
    }
   
//~     moved that inside
    var cname = "PoloPreferences";
    var cvalue =  encodeURIComponent(window.mutelist.join(','));
    var exdays = 356;
//~     setCookie("PoloPreferences", escape(window.mutelist.join(';')), 356);
//~     function setCookie(cname, cvalue, exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays*24*60*60*1000));
        var expires = "expires="+d.toUTCString();

        document.cookie = cname + "=" + cvalue + "; " + expires;
//~     }
}

window.newgetTrollboxRow = function(trollboxRow){
    if(window.mutelist.indexOf(trollboxRow['username'].substr(0,16)) >= 0)
    {
        // a bit greyed out
        // http://www.w3schools.com/html/html_colors.asp
        trollboxRowContent = '';
        trollboxRowContent += ''; //this is a bit heavy
//~         trollboxRowContent += '';
//~         trollboxRowContent += trollboxRow['username'] + ": ";
//~         trollboxRowContent += '
';
        trollboxRowContent += trollboxRow['username'] + ": ";
        trollboxRowContent += trollboxRow['message'];
        trollboxRowContent += '
';
        trollboxRowContent += '
';
    }

    else if(window.VIPlist.indexOf(trollboxRow['username']) >= 0)
    {
        trollboxRowContent = '';
        trollboxRowContent += '';
        trollboxRowContent += trollboxRow['username'] + ": ";
        trollboxRowContent += '
';
        trollboxRowContent += trollboxRow['message'];
        trollboxRowContent += '
';
    }

    // for our own chat, disable reply klickability since it always looks bad if we seem to talk
    // with ourselfes, doesn't it? Always klicking me in an ongoing conversation :-(
    else if(trollboxRow['username'] == trollboxUsername && trollboxRow['message'].substring(0,3) != "/me")
    {
        //trollboxRowContent = '';
        trollboxRowContent = '';
        trollboxRowContent += trollboxRow['username'] + ": ";
        trollboxRowContent += '
';
        trollboxRowContent += trollboxRow['message'];
        trollboxRowContent += '
';
    }

    else {
        // all other cases are for the original function
// I have a feeling the filtering for "'s or other suspicious stuff
// is done server-side in a different language, like C
        trollboxRowContent = pologetTrollboxRow(trollboxRow);
    }

    //our interface button always goes in front
    trollboxRowContent = '' + trollboxRowContent;
    // ⊗
   
    return trollboxRowContent;
}

window.runkit_function_rename = function(funcname, newname){
    // http://kevin.vanzonneveld.net
    // +   original by: Brett Zamir (http://brett-zamir.me)
    // %          note 1: Function can only be copied to and from the global context
    // *     example 1: function plus (a, b) { return (a + b); }
    // *     example 1: runkit_function_rename('plus', 'add');
    // *     returns 1: true
//~     we had to loosen it's resistance to mess with things a bit
//~     if(typeof this.window[newname] !== 'function' || this.window[funcname] !== undefined)
//~       return false; //presumably disallow overwriting existing variables
    this.window[newname] = this.window[funcname];
    this.window[funcname] = undefined;
    return true;
}

function check(node, value){
    var childNode = document.getElementById(node);
    if(childNode != null)
        childNode.checked = value;
    else
        log("no checkbox "+node+" found");
}

function setvalue(node, value){
    var childNode = document.getElementById(node);
    if(childNode != null)
        childNode.value = value;
    else
        log("no entry "+node+" found");
}

function replaceText(whichClass, fromString, toString){
   var hits = document.querySelectorAll("."+whichClass);
   for(var i = 0; i < hits.length; i++) {
      var text = hits[i].innerHTML;
      if(text.search(fromString) >= 0)
          hits[i].innerHTML = text.replace(fromString, toString);
   }
}

function exists(id){
   if(document.getElementById(id) != null) return true;
   return false;
}

var appendError = function(str){
   throw new Error("DEBUG: "+str);
}

function log(str){
   setTimeout("appendError('"+str+"')", 1);
}

//
if(exists("hideCheckbox"))
{
    check("hideCheckbox", true);
    POL.render.balances();
}

// if we are on a page with charts, adjust SMA,EMA,Bollinger,Fibonacci,Trollbox
if(exists("fibCheckbox")) {

    //hinge in some hasty hitches
    var cookie = decodeURIComponent(getCookie("PoloPreferences"));
    if(cookie != "") window.mutelist = cookie.split(',');
    runkit_function_rename("getTrollboxRow", "pologetTrollboxRow");
    runkit_function_rename("newgetTrollboxRow", "getTrollboxRow");

    //
    check("depthCheckbox", true);
    $("#depthChartContainer").hide();

    //check("swapCheckbox", true); //seems to be persistent :)
   
    setvalue("smaPeriod", 15);
    check("smaCheckbox", true);

    setvalue("emaPeriod", 99);
    check("emaCheckbox", true);
    // it is too small! any above 100 needs more, but more pixels mess up the table layout
    //
    //document.getElementById("emaPeriod").style.width = "40px";

    setvalue("ema2eriod", 100);
    check("ema2heckbox", false);

    check("bollingerCheckbox", false);
    check("fibCheckbox", false);

    if(false){
    //we choose "5-min candlesticks"
    changeChartType(300);
    //'300', '900', '1800', '7200', '14400', '86400'
    //we choose "last day, 24h"
    chartSnapZoom(24);
    }

    // Trollbox
    replaceText("hStyleBig", "Trollbox", "Home Sweet Home");
    // my donation address is at
    // BTC 12RfcMPgJWmV2kxfL3mT22DPbLCoJWdFbB
    // LTC LeKzdb8DZiwZUvDnT53uDuvSid3fXa4bMc
    //
    // body.exchangePage #trollbox{
    // border:1px solid black;
    // width:497px;
    // height:390px;
    changecss("body.exchangePage #trollbox", "height", "650px");
    changecss("body.exchangePage #trollbox", "border", "2px solid blue");

    replaceText("hStyle", "Sell Orders", "sell,Sell,SELL");
    replaceText("hStyle", "Buy Orders", "buy,Buy,BUY");
}
//all parts created by Njall, unless otherwise stated, in 9.2014
//eof
Jump to: