do some terrible things to selenium so devtools might work

This commit is contained in:
Artemis Tosini 2024-03-27 01:24:24 +00:00
parent 001e325e78
commit e364bd3657
Signed by: artemist
GPG key ID: EE5227935FE3FF18
5 changed files with 60 additions and 10 deletions

View file

@ -78,18 +78,49 @@
rust-form
svd2rust
svdtools
];
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
};
devShells.avr = with pkgs; pkgsCross.avr.mkShell {
packages = [
avrdude
gnumake
];
devShells.avr = with pkgs;
pkgsCross.avr.mkShell {
packages = [ avrdude gnumake ];
LIBC = pkgsCross.avr.avrlibc;
};
LIBC = pkgsCross.avr.avrlibc;
};
devShells.emoji = with pkgs;
mkShell {
packages = [
chromedriver
chromium
python3
python3Packages.black
python3Packages.ipython
(python3Packages.selenium.overrideAttrs (old: {
postInstall = old.postInstall + ''
for ver in v85 v120 v121 v122; do
DEVTOOLS=../common/devtools/chromium/$ver
for proto in js browser; do
python3 ../common/devtools/convert_protocol_to_json.py \
$DEVTOOLS/"$proto"_protocol.pdl \
--map_binary_to_string=true \
$DEVTOOLS/"$proto"_protocol.json
done
mkdir -p $DST_PREFIX/common/devtools/$ver
python3 generate.py \
$DEVTOOLS/browser_protocol.json \
$DEVTOOLS/js_protocol.json \
$DST_PREFIX/common/devtools/$ver
done
'';
nativeBuildInputs = old.nativeBuildInputs
++ [ python3Packages.inflection ];
}))
];
CHROME = "${chromium}/bin/chromium";
};
devShells.typst = with pkgs; mkShell { packages = [ typst ]; };
formatter = pkgs.nixfmt;
});

1
scripts/emoji/.envrc Normal file
View file

@ -0,0 +1 @@
use flake ../..#emoji

1
scripts/emoji/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
out

View file

@ -1,5 +1,4 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3
#!/usr/bin/env python3
import json
import zlib
import sys

18
scripts/emoji/scrape_guilds.py Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env python3
import os.path
import os
from selenium import webdriver
options = webdriver.ChromeOptions()
if location := os.getenv("CHROME"):
options.binary_location = location
options.add_argument("--start-maximized")
options.add_argument(
"--user-data-dir=" + os.path.expanduser("~/.cache/chromium-emoji-script")
)
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(options=options)
# Selenium says this API is deprecated but there's no better working option in Python
# (okay, maybe there is but they don't really have docs)