Skip to content

Instantly share code, notes, and snippets.

View serebano's full-sized avatar

Sergiu Toderascu serebano

View GitHub Profile
/**
* Type utils
*/
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
function deepAssign(
target: Record<string, any>,
...sources: Record<string, any>[]
) {
@serebano
serebano / importWithFetch.js
Created August 7, 2024 15:32
Import remote module using fetch. Works in browser/node/deno/bun
fetch("https://gist.github.com/serebano/83304400d6141751c38202bb66d14f83/raw")
.then(async (r) => (await import(`data:application/javascript;base64,${btoa(await r.text())}`)))
export default function RequestModule() {
/**
* Type utils
*/
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
function deepAssign(
target: Record<string, any>,
...sources: Record<string, any>[]
) {
export default function RequestModule() {
function deepAssign(target, ...sources) {
for (const source of sources) {
for (const k in source) {
const vs = source[k],
vt = target[k];
if (Object(vs) == vs && Object(vt) === vt) {
target[k] = deepAssign(vt, vs);
continue;
}
export const modURL = () => URL.createObjectURL(new Blob([new Uint8Array([47,42,42,10,32,42,32,84,121,112,101,32,117,116,105,108,115,10,32,42,47,10,116,121,112,101,32,83,105,109,112,108,105,102,121,60,84,62,32,61,32,123,32,91,75,101,121,84,121,112,101,32,105,110,32,107,101,121,111,102,32,84,93,58,32,84,91,75,101,121,84,121,112,101,93,32,125,59,10,10,102,117,110,99,116,105,111,110,32,100,101,101,112,65,115,115,105,103,110,40,10,32,32,32,32,116,97,114,103,101,116,58,32,82,101,99,111,114,100,60,115,116,114,105,110,103,44,32,97,110,121,62,44,10,32,32,32,32,46,46,46,115,111,117,114,99,101,115,58,32,82,101,99,111,114,100,60,115,116,114,105,110,103,44,32,97,110,121,62,91,93,10,41,32,123,10,32,32,32,32,102,111,114,32,40,99,111,110,115,116,32,115,111,117,114,99,101,32,111,102,32,115,111,117,114,99,101,115,41,32,123,10,32,32,32,32,32,32,32,32,102,111,114,32,40,99,111,110,115,116,32,107,32,105,110,32,115,111,117,114,99,101,41,32,123,10,32,32,32,32,32,32,32,32,32,32,32,32,99,111,110,115,116,32,118,115,32,61,32,115,111,11
const myModule = await import(URL.createObjectURL(new Blob(
[`
// module code inside this template literal
`],
{type: "text/javascript"},
)));
@serebano
serebano / get-html.js
Created November 13, 2021 03:37
scrapp.page/function
module.exports = async ({ page, context }) => {
//const { url } = context;
const url = 'https://example.com'
await page.goto(url);
const data = await page.content();
return {
data,
// Make sure to match the appropriate content here
@serebano
serebano / google-search.js
Last active November 13, 2021 03:29
scrapp.page/function
module.exports = async({ page }) => {
await page.goto('https://google.com/');
await page.click('button#L2AGLb', {
clickCount: 1,
delay: 200
});
await page.type('input[type="text"]', 'whats new around');
export default (ctx) => ({ ctx, res: Promise.resolve(123) })
@serebano
serebano / altpop.html
Last active July 23, 2020 14:05
alternative pop-up
<a
style="display:block;position:fixed;z-index:9999999;width:100%;height:100%;top:0;left:0"
href="/"
target="_blank"
onclick="setTimeout(function(){ document.location.href='https://example.com' }, 100)">
</a>