Skip to content

Instantly share code, notes, and snippets.

const CACHE_NAME = 'my-cache-v1';
// هنگام نصب Service Worker، می‌تونیم فایل‌های اولیه رو کش کنیم
self.addEventListener('install', (event) => {
console.log('[Service Worker] Installing...');
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
console.log('[Service Worker] Pre-caching some assets');
return cache.addAll([
'/', // index.html
@maanimis
maanimis / Heading-Fragment-Linker.userscript.js
Created August 5, 2025 05:51
Add clickable fragment links to all headings
// ==UserScript==
// @name Heading Fragment Linker
// @namespace http://tampermonkey.net/
// @version 2.0
// @description Add clickable fragment links to all headings
// @author maanimis
// @match *://*/*
// @grant none
// @license MIT
// ==/UserScript==
@maanimis
maanimis / WebSocketMultiplexer.userscript.js
Last active August 8, 2025 07:47
Intercepts WebSocket connections and creates multiple connections instead of one(with Reconnect)
// ==UserScript==
// @name WebSocket Connection Multiplier+Reconnect
// @namespace http://tampermonkey.net/
// @version 3.1
// @description Intercepts WebSocket connections and creates multiple connections instead of one
// @author maanimis
// @match https://example.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=example.com
// @grant none
// @run-at document-start
@maanimis
maanimis / ws.multi.connection.userscript.js
Created July 26, 2025 10:53
Here's a userscript that hooks WebSocket connections and creates multiple connections instead of one. This script intercepts the WebSocket constructor and automatically creates additional connections when a new WebSocket is initiated
// ==UserScript==
// @name WebSocket Multi-Connection Hook
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Create multiple WebSocket connections instead of one
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==
@maanimis
maanimis / script-replacer.userscript.js
Created July 23, 2025 14:00
Replace bundle.js script with custom URL
// ==UserScript==
// @name Bundle.js Replacer
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Replace bundle.js script with custom URL
// @author You
// @match *://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
@maanimis
maanimis / concurrent-xhr-workers.js
Created June 29, 2025 15:41
This script sends a specified number of concurrent HTTP requests using Web Workers at a scheduled future time.
{
const TARGET_URL = "https://crypto.cloudflare.com/cdn-cgi/trace";
const METHOD = "GET";
const CONCURRENT_REQUESTS = 10;
const PAYLOAD = {};
const HEADERS = {};
const START_AT_MS = Date.now() + 3000;
const workerCode = `
@maanimis
maanimis / docker-compose.yml
Created June 28, 2025 08:39
for mysql and phpmyadmin
version: '3'
services:
mysql:
image: mysql
container_name: tutorial-mysql
environment:
- MYSQL_ROOT_PASSWORD=toor
networks:
- tutorial
@maanimis
maanimis / Dockerfile
Created June 28, 2025 08:33
for nodejs
FROM node:22.17-alpine3.21
RUN addgroup app && adduser -S -G app app
USER app
WORKDIR /app
RUN mkdir log
COPY package.json .
RUN npm install
COPY . .
ENV API_URL=https://example.com/API_URL
EXPOSE 3000
@maanimis
maanimis / extract-urls.js
Created May 26, 2025 23:23
Utility to extract TradingView script URLs
import fs from 'fs';
import readline from 'readline';
// Utility to extract TradingView script URLs (with or without protocol)
function extractTradingViewLinks(line) {
const regex = /(?:https?:\/\/)?(?:[a-z]+\.)?tradingview\.com\/script\/[a-zA-Z0-9-_]+/g;
return line.match(regex) || [];
}
// Main function to process files