Skip to content

Instantly share code, notes, and snippets.

@micwoj92
Last active October 8, 2023 19:02
Show Gist options
  • Save micwoj92/8d3557d75c10fa8c4251f4753e1ace21 to your computer and use it in GitHub Desktop.
Save micwoj92/8d3557d75c10fa8c4251f4753e1ace21 to your computer and use it in GitHub Desktop.
Userscript to show top rows on king of stackers
// ==UserScript==
// @name show top rows
// @version 0.1
// @author budhole
// @match https://kingofstackers.com/game.php?*
// @grant none
// ==/UserScript==
for(var t = 1; t < 3; t++){
var TABLE = document.querySelector("table#field" + t + " > tbody");
for(var i = 25; i > 20; i--){
var row = document.createElement("tr");
for(var j = 1; j < 11; j++){
var col = document.createElement("td");
col.className = "cell";
col.id = "cell" + t + "_" + i + "_" + j;
row.appendChild(col);
}
TABLE.insertBefore(row, TABLE.childNodes[0]);
}
}
window.redraw_field = function(number) {
for(var line=1;line<=25;line++) {
for(var cell=1;cell<=10;cell++) {
id="cell"+number+"_"+line+"_"+cell;
color_field_cell(number, cell, line, colors[field[number][line][cell]]);
}
}
redraw_ghost(number);
if( next[1][0] == '-' ) return;
for(var i=0;i<4;i++) {
color_field_cell(number,
x+overlaptable[next[1][0]][rotationstate][i].x,
y+overlaptable[next[1][0]][rotationstate][i].y,
colors[next[1][0]]);
}
};
window.color_field_cell = function(fn, x, y, color) {
if( x < 1 || x > 10 || y < 1 || y > 25 ) {
return;
}
if(y > 0 && y < 6) y += 25;
color_cell(fn, y-5, x, color);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment