Skip to content

Instantly share code, notes, and snippets.

@zoutepopcorn
Last active March 15, 2019 13:19
Show Gist options
  • Save zoutepopcorn/bceec002bacb1cc2b499277128451e40 to your computer and use it in GitHub Desktop.
Save zoutepopcorn/bceec002bacb1cc2b499277128451e40 to your computer and use it in GitHub Desktop.
overheid kleuren online
// ==UserScript==
// @name Kleuren rijksoverheid
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author You
// @match https://www.rijkshuisstijl.nl/basiselementen/*
// @grant GM_setClipboard
// ==/UserScript==
var kleuren
(function() {
'use strict';
const REG_KLEUR = /(?:#)[0-9a-f]{8}|(?:#)[0-9a-f]{6}|(?:#)[0-9a-f]{4}|(?:#)[0-9a-f]{3}/ig
kleuren = []
document.querySelectorAll('.contentBox > p').forEach((inner) => {
const ITEMS = inner.innerText.split('\n')
let tmpNaam = ""
let tmpCount = 0;
ITEMS.forEach((line) => {
const KLEUR = line.match(REG_KLEUR)
if(KLEUR) {
let TMP1 = line.substring(0,line.indexOf(KLEUR)).toLowerCase()
let NAAM = TMP1.replace(/[^a-z]/g, '')
if(NAAM.includes("tint")) {
NAAM = `${tmpNaam}-${++tmpCount}`
} else {
tmpNaam = NAAM
tmpCount = 0
}
kleuren.push({naam: NAAM.replace(" ", ""), kleur: KLEUR[0]})
}
})
})
console.log("kijk op uw klembord")
GM_setClipboard(JSON.stringify(kleuren), "json")
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment