Bitcoin Forum
June 25, 2024, 06:21:57 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Poloniex convenience modifications  (Read 1115 times)
This is a self-moderated topic. If you do not want to be moderated by the person who started this topic, create a new topic.
Njall (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
September 09, 2014, 03:51:37 PM
Last edit: September 13, 2014, 11:42:53 PM by Njall
 #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<ca.length; 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 = '<span style="color:rgb(192,192,192);">';
        trollboxRowContent += '<s>'; //this is a bit heavy
//~         trollboxRowContent += '<strong><a onclick="$(\'#message\').val($(\'#message\').val() + \'' + trollboxRow['username'] + ', \');$(\'#message\').focus();">';
//~         trollboxRowContent += trollboxRow['username'] + ": ";
//~         trollboxRowContent += '</a></strong>';
        trollboxRowContent += trollboxRow['username'] + ": ";
        trollboxRowContent += trollboxRow['message'];
        trollboxRowContent += '</s>';
        trollboxRowContent += '</span>';
    }

    else if(window.VIPlist.indexOf(trollboxRow['username']) >= 0)
    {
        trollboxRowContent = '<span style="font-weight:900;"><strong>';
        trollboxRowContent += '<a onclick="$(\'#message\').val($(\'#message\').val() + \'' + trollboxRow['username'] + ', \');$(\'#message\').focus();">';
        trollboxRowContent += trollboxRow['username'] + ": ";
        trollboxRowContent += '</a></strong>';
        trollboxRowContent += trollboxRow['message'];
        trollboxRowContent += '</span>';
    }

    // 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 = '<span style="color:rgb(256,104,0);"><strong>';
        trollboxRowContent = '<span style="font-weight:900;"><strong>';
        trollboxRowContent += trollboxRow['username'] + ": ";
        trollboxRowContent += '</strong>';
        trollboxRowContent += trollboxRow['message'];
        trollboxRowContent += '</span>';
    }

    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 = '<a onclick="muteOnClick(\'' + trollboxRow['username'] + '\');"><img src="/images/theme_light/community.png"  style="width:28px; height:14px; margin-right: 4px;" /></a>' + trollboxRowContent;
    // &otimes;
   
    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);
}

// <label for="hideCheckbox">Hide balances of zero</label>
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");

    //<input id="depthCheckbox" type="checkbox"><label for="depthCheckbox"> Hide Depth Chart</label>
    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
    // <input id="emaPeriod" style="width:30px;" value="100" type="text">
    //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);
    }

    // <span class="hStyleBig">Trollbox</span>
    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
Njall (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
September 09, 2014, 04:03:14 PM
 #2

reserved
cynicSOB
Member
**
Offline Offline

Activity: 106
Merit: 10

yes, sometimes I'm a cynical SOB


View Profile
September 09, 2014, 05:12:56 PM
 #3

but what does it do? what are its features

trollbox filter is nice

For more secure coins: 1EqekC9YVhiWLYjG3mfKNJwrf5s3YS46WW
For the lulz:1EqekC9YVhiWLYjG3mfKNJwrf5s3YS46WW
Njall (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
September 09, 2014, 07:28:16 PM
Last edit: September 11, 2014, 09:28:22 AM by Njall
 #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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!