Skip to content

Instantly share code, notes, and snippets.

@flarn2006
Created December 11, 2019 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flarn2006/314cf69e088e41f85f462dd8eb29b143 to your computer and use it in GitHub Desktop.
Save flarn2006/314cf69e088e41f85f462dd8eb29b143 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name All GauGAN Labels
// @version 1
// @grant none
// @include http://34.216.122.111/gaugan/
// ==/UserScript==
function selectCategoryAll()
{
var palette = document.getElementById('palette');
palette.innerHTML = '<table><tbody></tbody><table>';
palette = palette.querySelector('tbody');
[].forEach.call(unsafeWindow.labels, function(lbl) {
var tr = document.createElement('tr');
var th = document.createElement('th');
var button = document.createElement('button');
button.classList.add('btnclr');
button.classList.add(lbl);
button.innerText = lbl[4].toUpperCase() + lbl.slice(5);
button.onclick = function() {
unsafeWindow.current_color = unsafeWindow.colors[unsafeWindow.labels.indexOf(lbl)];
};
th.appendChild(button);
tr.appendChild(th);
palette.appendChild(tr);
});
}
window.addEventListener('load', function() {
var pstyle = document.getElementById('palette').style;
pstyle.maxHeight = '360px';
pstyle.overflowY = 'scroll';
var categoryList = document.querySelector('#category tr').parentNode;
var tr = document.createElement('tr');
var th = document.createElement('th');
var button = document.createElement('button');
button.classList.add('btncat');
button.classList.add('cat-all');
button.innerText = 'All';
button.onclick = selectCategoryAll;
th.appendChild(button);
tr.appendChild(th);
categoryList.appendChild(tr);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment