init

mmatt.net 3793cd8d

+11
README.md
··· 1 + # Deer Direct - Chrome Extension 2 + 3 + A Chrome extension that automatically redirects any links from `bsky.app/*` to `deer.social/*`. 4 + 5 + ## Installation 6 + 7 + 1. Download or clone this repository 8 + 2. Open Chrome and go to `chrome://extensions/` 9 + 3. Enable "Developer mode" in the top right 10 + 4. Click "Load unpacked" and select the extension folder 11 + 5. The extension will now automatically redirect bsky.app links to deer.social
+60
content.js
··· 1 + // Content script to handle redirects on the page level 2 + (function() { 3 + 'use strict'; 4 + 5 + // Function to redirect current page if it's on bsky.app 6 + function redirectCurrentPage() { 7 + if (window.location.hostname === 'bsky.app') { 8 + const newUrl = window.location.href.replace('bsky.app', 'deer.social'); 9 + window.location.replace(newUrl); 10 + } 11 + } 12 + 13 + // Function to handle clicks on links 14 + function handleLinkClicks(event) { 15 + const target = event.target.closest('a'); 16 + if (target && target.href && target.href.includes('bsky.app')) { 17 + event.preventDefault(); 18 + const newUrl = target.href.replace('bsky.app', 'deer.social'); 19 + window.location.href = newUrl; 20 + } 21 + } 22 + 23 + // Function to update existing links on the page 24 + function updateLinks() { 25 + const links = document.querySelectorAll('a[href*="bsky.app"]'); 26 + links.forEach(link => { 27 + if (link.href.includes('bsky.app')) { 28 + link.href = link.href.replace('bsky.app', 'deer.social'); 29 + } 30 + }); 31 + } 32 + 33 + // Redirect immediately if we're on bsky.app 34 + redirectCurrentPage(); 35 + 36 + // Add click listener for any remaining links 37 + document.addEventListener('click', handleLinkClicks, true); 38 + 39 + // Update links when DOM changes (for dynamic content) 40 + const observer = new MutationObserver(function(mutations) { 41 + mutations.forEach(function(mutation) { 42 + if (mutation.type === 'childList') { 43 + updateLinks(); 44 + } 45 + }); 46 + }); 47 + 48 + // Start observing 49 + observer.observe(document.body, { 50 + childList: true, 51 + subtree: true 52 + }); 53 + 54 + // Also update links on page load 55 + if (document.readyState === 'loading') { 56 + document.addEventListener('DOMContentLoaded', updateLinks); 57 + } else { 58 + updateLinks(); 59 + } 60 + })();
+58
create_icons.html
··· 1 + <!DOCTYPE html> 2 + <html> 3 + <head> 4 + <title>Create Extension Icons</title> 5 + </head> 6 + <body> 7 + <h1>Extension Icon Generator</h1> 8 + <p> 9 + This HTML file can be used to generate simple icons for the extension. 10 + </p> 11 + <p> 12 + For now, you can use any 16x16, 48x48, and 128x128 pixel images as 13 + icon16.png, icon48.png, and icon128.png respectively. 14 + </p> 15 + 16 + <canvas 17 + id="icon16" 18 + width="16" 19 + height="16" 20 + style="border: 1px solid #ccc" 21 + ></canvas> 22 + <canvas 23 + id="icon48" 24 + width="48" 25 + height="48" 26 + style="border: 1px solid #ccc" 27 + ></canvas> 28 + <canvas 29 + id="icon128" 30 + width="128" 31 + height="128" 32 + style="border: 1px solid #ccc" 33 + ></canvas> 34 + 35 + <script> 36 + // Create simple icons 37 + function createIcon(canvasId, size) { 38 + const canvas = document.getElementById(canvasId); 39 + const ctx = canvas.getContext("2d"); 40 + 41 + // Background 42 + ctx.fillStyle = "#4A90E2"; 43 + ctx.fillRect(0, 0, size, size); 44 + 45 + // Text "D" 46 + ctx.fillStyle = "white"; 47 + ctx.font = `bold ${size * 0.6}px Arial`; 48 + ctx.textAlign = "center"; 49 + ctx.textBaseline = "middle"; 50 + ctx.fillText("D", size / 2, size / 2); 51 + } 52 + 53 + createIcon("icon16", 16); 54 + createIcon("icon48", 48); 55 + createIcon("icon128", 128); 56 + </script> 57 + </body> 58 + </html>
icon128.png

This is a binary file and will not be displayed.

icon16.png

This is a binary file and will not be displayed.

icon48.png

This is a binary file and will not be displayed.

+23
manifest.json
··· 1 + { 2 + "manifest_version": 3, 3 + "name": "Deer Direct - Bluesky to Deer Redirect", 4 + "version": "1.0", 5 + "description": "Automatically redirects bsky.app links to deer.social", 6 + "permissions": ["declarativeNetRequest"], 7 + "host_permissions": ["https://bsky.app/*"], 8 + "declarative_net_request": { 9 + "rule_resources": [ 10 + { 11 + "id": "ruleset_1", 12 + "enabled": true, 13 + "path": "rules_1.json" 14 + } 15 + ] 16 + }, 17 + "content_scripts": [], 18 + "icons": { 19 + "16": "icon16.png", 20 + "48": "icon48.png", 21 + "128": "icon128.png" 22 + } 23 + }
+16
rules_1.json
··· 1 + [ 2 + { 3 + "id": 1, 4 + "priority": 1, 5 + "action": { 6 + "type": "redirect", 7 + "redirect": { 8 + "regexSubstitution": "https://deer.social/\\1" 9 + } 10 + }, 11 + "condition": { 12 + "regexFilter": "^https://bsky\\.app/(.*)$", 13 + "resourceTypes": ["main_frame", "sub_frame"] 14 + } 15 + } 16 + ]