mardraze / kurnik.pl

// ==UserScript==
// @name         kurnik.pl
// @namespace    http://kurnik.pl/szachy
// @version      0.1
// @description  Chess analysing
// @author       mardraze
// @match        http://www.kurnik.pl/szachy/*
// @grant        none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    window.lichessPaste = function(){
        $('.tcrdpan button').first().click();
        
        var intervalPgn = setInterval(function(){
            var pngString = $('textarea.taplain').val();
            if(pngString){
                clearInterval(intervalPgn);
                window.open('https://pl.lichess.org/paste?pgn='+encodeURIComponent(pngString), "_blank", "toolbar=1, scrollbars=1, resizable=1, width=" + 1015 + ", height=" + 800);
            }
        }, 1000);
    };
    
    var interval = setInterval(function(){
        if(!document.getElementById('mardraze_chess_addon')){
            $('.trqcont').prepend('<div id="mardraze_chess_addon"><input type="button" value="Lichess" onclick="lichessPaste()"/></div>');
        }
    }, 1000);
})();