Skip to content

Instantly share code, notes, and snippets.

@HereOrCode
HereOrCode / wa-decrypt.js
Created February 19, 2025 10:49 — forked from Gimenz/wa-decrypt.js
a function to decrypt WA Media
/**
* this code is copied from https://github.com/open-wa/wa-decrypt-nodejs
* i just made it more simplified
*/
const { default: axios } = require('axios');
const crypto = require('crypto');
const hkdf = require('futoin-hkdf');
const atob = require('atob');
var saveBlob = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (blob, fileName) {
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
@HereOrCode
HereOrCode / Authenticate users with Google.md
Last active February 1, 2025 10:46
Chrome Extension: Authenticate users with Google

Code

export async function loginToGoogle() {
  const { code } = getAuthParams(
    (await chrome.identity.launchWebAuthFlow({
      interactive: true,
      url: `https://accounts.google.com/o/oauth2/v2/auth?${new URLSearchParams({
        redirect_uri: chrome.identity.getRedirectURL(import.meta.env.VITE_CHROME_EXT_ID),
 client_id: import.meta.env.VITE_GOOGLE_CLIENT_ID,
@HereOrCode
HereOrCode / command.md
Created January 11, 2025 09:16
Delete macOS .Ds_Store files
# Find DS_Store
alias fds="find . -name .DS_Store"

# Delete DS_Store
alias dds="find . -name .DS_Store -type f -delete"
@HereOrCode
HereOrCode / useDrag.ts
Last active February 3, 2024 07:45
React Hook: Draggable div element
import { useCallback, useEffect, useState } from "react";
type DragInfo = {
startX: number;
startY: number;
top: number;
left: number;
width: number;
height: number;
};
@HereOrCode
HereOrCode / fetchStream.js
Created January 17, 2024 00:56 — forked from blackbing/fetchStream.js
Server Sent Event with fetch stream
const url = 'https://api.example.com/v1/sse';
const accessToken = 'test';
fetch(url, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
.then(response => {
if (response.ok && response.body) {
reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
@HereOrCode
HereOrCode / demo.js
Last active October 24, 2023 11:11
Video auto play
/*
* Autoplay policy in Chrome - Chrome for Developers
* https://developer.chrome.com/blog/autoplay/#example_scenarios
*
* Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
* https://stackoverflow.com/a/68128950/7738653
*/
const video = document.querySelector("video");
@HereOrCode
HereOrCode / manifest.md
Created September 30, 2023 02:36
Manifest file format

Every extension requires a JSON-formatted file, named manifest.json, that provides important information. This file must be located in the extension's root directory.

https://developer.chrome.com/docs/extensions/mv3/manifest/

{
  "name": "crx-vue-multi-page",
 "description": "A Chrome extension demo.",
@HereOrCode
HereOrCode / jerry.swift
Created June 4, 2023 07:14 — forked from vorce/jerry.swift
Mouse move and click test thing for macos in swift
import Cocoa
import Foundation
// Move around and click automatically at random places in macos, kinda human like in a cheap way.
// Moves the mouse pointer to `moves` random locations on the screen and runs the `action` function at
// each point with the point as argument.
func mouseMoveWithAction(moves: Int, action: (CGPoint) -> Void = defaultAction) {
let screenSize = NSScreen.main?.visibleFrame.size
@HereOrCode
HereOrCode / index.js
Created January 31, 2023 09:30
translate file
const arguments = process.argv.slice(2);
const [filePath] = arguments;
main(filePath);
function main(filePath) {
const path = require('path');
const { root, dir, name, ext } = path.parse(filePath);