Skip to content

Instantly share code, notes, and snippets.

View ptjaworski's full-sized avatar

Patryk Jaworski ptjaworski

View GitHub Profile
@ptjaworski
ptjaworski / generate.js
Last active February 12, 2025 15:43
Generate a secret key
require('crypto').randomBytes(48, function(err, buffer) { var token = buffer.toString('hex'); console.log(token); });
// or
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
// or
openssl rand -base64 32
/**
* This part injects element before DOMContentLoaded event,
* and reaplies it each time React / Other framework rerenders the parent component.
*
* @returns void
*/
;(() => {
let observer;
function injectButton() {
@ptjaworski
ptjaworski / 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) {
@ptjaworski
ptjaworski / 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": {
@ptjaworski
ptjaworski / .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
@ptjaworski
ptjaworski / 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
@ptjaworski
ptjaworski / 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';"],