aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramelia <[email protected]>2023-08-20 02:10:39 -0500
committeramelia <[email protected]>2023-08-20 02:10:39 -0500
commite7bb33e17625d2e618f505769116a77dd39170f0 (patch)
tree19d91116a19157a0db882318fb8f0ddc7bb8631c
-rw-r--r--license.md7
-rw-r--r--main.js74
-rw-r--r--readme.md13
3 files changed, 94 insertions, 0 deletions
diff --git a/license.md b/license.md
new file mode 100644
index 0000000..ff74caa
--- /dev/null
+++ b/license.md
@@ -0,0 +1,7 @@
+Copyright © 2023 <[email protected]>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/main.js b/main.js
new file mode 100644
index 0000000..a00408c
--- /dev/null
+++ b/main.js
@@ -0,0 +1,74 @@
+const fs = require("fs")
+let file = process.argv[2]
+if(file==null||!fs.existsSync(file)){
+ console.log("please provide a file (idiot)")
+ process.exit(-8008)
+}
+function shuffle(array) {
+ //https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
+ let currentIndex = array.length, randomIndex;
+ while (currentIndex != 0) {
+ randomIndex = Math.floor(Math.random() * currentIndex);
+ currentIndex--;
+ [array[currentIndex], array[randomIndex]] = [
+ array[randomIndex], array[currentIndex]];
+ }
+ return array;
+}
+function css_parse(content){
+ let split = [];
+ let head = "";
+ let current = "";
+ let open = 0;
+ for(let c of content){
+ if(c=='{'){
+ open++;
+ }
+ if(open==0){
+ head+=c;
+ }
+ if(open>0){
+ current+=c;
+ }
+ if(c=='}'){
+ open--;
+ if(open==0){
+ current = current.slice(1).slice(0,-1)
+ split.push({head:head,content:current})
+ current="";
+ head="";
+ }
+ }
+
+ }
+ return split;
+}
+function r_sizing(css){
+ let units = ["cm","mm","Q","in","pc","pt","px","em",
+ "ex","ch","rem","lh","rlh","vw","vh","vmin","vmax",
+ "vb","vi","svw","svh","lvw","lvh","dvw","dvh","%"]
+ for(let c in css){
+ let split = (css[c].content.replace(/\n/g,'').split(';')).filter(function (e) {return e !== "";})
+ for(let s in split){
+ for(let u of units){
+ let reg = new RegExp("\\d+(\\.\\d+)?"+u,"g")
+ while(match = reg.exec(split[s])){
+ split[s] = split[s].substring(0,match.index+match[0].length-u.length) +
+ units[Math.floor(Math.random()*units.length)] + split[s].substring(match.index+match[0].length,split[s].length)
+ }
+
+ }
+ }
+ css[c].content = shuffle(split).join(';')+';'
+ }
+ return css;
+}
+function r_const(css){
+ let out = "";
+ for(let c of css){
+ out+=c.head+"{"+c.content+"}"
+ }
+ return out;
+}
+
+console.log(r_const(shuffle(r_sizing(css_parse(fs.readFileSync(file).toString())))))
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..3a37963
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,13 @@
+## ass, abstract style sheets
+
+a stupid language that transpiles css to css, written in (your favorite!) nodejs, probably faster than rust
+
+features:
+
+* randomize rule order
+* randomize property values
+* randomize measurements
+
+usage:
+
+`node main.js {file}`