Skip to content

Instantly share code, notes, and snippets.

View gerwld's full-sized avatar

Patryk Jaworski gerwld

View GitHub Profile
@gerwld
gerwld / reactInject.js
Created February 1, 2025 11:56
Inject script for DOM that often rerenders on start
(() => {
function injectButton(parent) {
if (parent.querySelector(".pf_lb2")) return; // Prevent duplicates
const wrapper = document.createElement("div");
wrapper.innerHTML = `<!-- CONTENT -->`;
parent.prepend(wrapper);
}
function waitForReactElement(attempts = 0, maxAttempts = 100) {
@gerwld
gerwld / typescript.json
Last active February 23, 2025 11:41
Snippets for TS
{
// CMD Shift P > Snippets: Configure Snippets
"Add Module exports": {
"prefix": "me",
"body": ["module.exports = "],
"description": "Module exports"
},
"1": {
@gerwld
gerwld / .zshrc
Last active November 7, 2025 15:08
.zshrc config
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
export PATH="/usr/local/opt/ruby/bin:$PATH"
#17 java
# export JAVA_HOME=$(/usr/libexec/java_home -v 17)
/**
* This script automates the process of unblocking your own blocked Instagram users list.
* It unblocks users one-by-one to avoid hitting rate limits or breaking the page.
*
* WARNING: This function directly manipulates the DOM and depends on the current HTML
* structure of Instagram's website to work. If Instagram implements changes to the
* activity page layout, structure, or functionality, this script may break or cause
* unexpected behavior. Use at your own risk and always review code before running it.
**/
/**
* This script automates the process of deleting your own Instagram saved posts.
*
* Tested on 12429 posts - around 4h non-stop working script on the background tab. Result: Success! 0 saved.
*
* WARNING: This function directly manipulates the DOM and depends on the current HTML
* structure of Instagram's website to work. If Instagram implements changes to the
* activity page layout, structure, or functionality, this script may break or cause
* unexpected behavior. Use at your own risk and always review code before running it.
*
/**
* More robust Instagram "unlike all" script for the Likes activity page.
* Paste on: https://www.instagram.com/your_activity/interactions/likes
*
* Note: Still brittle (depends on Instagram's DOM). Use at your own risk.
*/
; (async function () {
const DELETION_BATCH_SIZE = 9
const DELAY_BETWEEN_ACTIONS_MS = 1200
const DELAY_BETWEEN_WENTWRONG_MS = 3000000
@gerwld
gerwld / gist:6c733026f9f3576a7b5450e98b8915ec
Created December 8, 2024 09:55
Trigger any event placed in IIFE / etc
const element = temp1;
// Create a 'mouseenter' event
const event = new MouseEvent('mouseover', {
bubbles: true, // Ensures the event bubbles up (if needed)
cancelable: true, // Allows the event to be canceled
view: window // Links the event to the window object
});
// Dispatch the event on the element
@gerwld
gerwld / typescriptreact.json
Last active March 14, 2025 17:55
Snippets for Typescript React
// To open and edit javascriptreact.json in VS Code:
// Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the Command Palette.
// Type Preferences: Configure User Snippets and select it.
// Choose javascriptreact.json from the list.
{
"Add Styles Import": {
"prefix": "ims",
"body": ["import style from './style.module.css';"],

Several key techniques and best practices to help make JavaScript run extremely fast. Some of these involve optimizing how you handle objects, memory, and data structures, as well as leveraging modern JavaScript engine optimizations. Here are some key points:

1. Use Object.create(null) for Pure Maps/State Objects

  • When you create objects using {}, they inherit from Object.prototype, which can introduce unnecessary properties and methods. Using Object.create(null) creates an object with no prototype, making it a cleaner and faster option for objects used purely as maps or state stores. This reduces overhead from the prototype chain.

2. Avoid Creating Objects in Loops

  • Repeatedly creating objects inside a loop can lead to excessive memory allocations and garbage collection. Instead, reuse objects where possible or move object creation outside the loop.

3. Minimize the Use of Closures in Performance-Critical Code

  • While closures are powerful, they can sometimes lead
@gerwld
gerwld / instagram-likes-activity-deleter.js
Last active September 12, 2024 20:01
Instagram Likes Activity Deleter: Automate the deletion of all your Instagram likes from the 'Your Activity' section. Perfect for quick digital clean-up.
/**
* This script automates the process of deleting your own Instagram likes.
* It deletes comments in batches to avoid hitting rate limits or breaking the page.
*
* WARNING: This function directly manipulates the DOM and depends on the current HTML
* structure of Instagram's website to work. If Instagram implements changes to the
* activity page layout, structure, or functionality, this script may break or cause
* unexpected behavior. Use at your own risk and always review code before running it.
*
* How to use: