dotfiles/plugins/tampermonkey-mzte/src/Macro.hx
LordMZTE f084f919e6
use browser app for shitcord
one small step closing to completely ridding myself of this heap of
garbage
2024-03-25 22:54:11 +01:00

34 lines
953 B
Haxe

#if macro
import haxe.macro.Compiler;
import haxe.macro.Context;
import sys.FileSystem;
import sys.io.File;
#end
using StringTools;
var assetRoot = "../../cgout/cgassets/tampermonkey-mzte";
macro function init() {
var oldHeader = Context.definedValue("source-header");
var header = Std.string(File.read('$assetRoot/header.txt').readAll());
Compiler.define("source-header", '$header\n//$oldHeader');
return macro {};
}
macro function fileContent(path:String):haxe.macro.Expr.ExprOf<String> {
return macro $v{Std.string(File.read('$assetRoot/$path').readAll())};
}
macro function siteStyles():haxe.macro.Expr.ExprOf<Map<String, String>> {
var map:Array<haxe.macro.Expr> = [];
for (f in FileSystem.readDirectory('$assetRoot/site_styles')) {
if (f.endsWith(".css")) {
map.push(macro $v{f.substr(0, f.length - 4)} => Macro.fileContent($v{'site_styles/$f'}));
}
}
return macro $a{map};
}