Skip to content

A Chrome extension that allows you to instantly share the current webpage to your Telegram channel or chat with an optional caption.

Notifications You must be signed in to change notification settings

thihakyaw/telegram-snapshare

Repository files navigation

Telegram SnapShare 📸📱

A Chrome extension that allows you to instantly share the current webpage to your Telegram channel or chat with an optional caption.

✨ Features

  • One-click sharing - Share any webpage to Telegram instantly
  • Custom captions - Add personalized captions to your shared links
  • Query parameter preservation - Preserves important URL parameters while removing fragments
  • Secure credential storage - Bot tokens are encrypted before storage
  • Bot token testing - Verify your Telegram bot credentials before use
  • Channel support - Works with both public and private Telegram channels
  • Modern UI - Clean, intuitive interface with real-time feedback

🚀 Quick Start

1. Create a Telegram Bot

  1. Open Telegram and message @BotFather
  2. Send /newbot and follow the instructions
  3. Save your bot token (looks like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)

2. Set Up Your Channel

  1. Add your bot to your target channel as an administrator
  2. Get your channel ID:
    • Public channels: Use @channelname (e.g., @mychannel)
    • Private channels: Use the numeric ID (e.g., -1001234567890)

3. Install the Extension

# Clone and build
git clone <repository-url>
cd telegram-snapshare
npm install
./build.sh

# Load in Chrome
1. Open chrome://extensions/
2. Enable "Developer mode"
3. Click "Load unpacked"
4. Select the telegram-snapshare folder

4. Configure Credentials

  1. Click the extension icon
  2. Go to Settings tab
  3. Enter your Bot Token and Chat ID
  4. Click Test Bot Token to verify
  5. Click Save Credentials

🎯 Usage

  1. Navigate to any webpage you want to share
  2. Click the Telegram SnapShare extension icon
  3. Add a caption (optional) in the text area
  4. Click "Share to Telegram"

The extension will automatically process the URL (preserving query parameters) and send it to your configured Telegram channel!

🔒 Security Features

Encrypted Bot Token Storage

  • Bot tokens are encrypted using base64 encoding with salt before storage
  • Provides basic obfuscation to protect sensitive credentials
  • Backward compatible with existing unencrypted tokens

Secure Chrome Storage

  • Uses Chrome's chrome.storage.sync API for secure credential storage
  • Data is synchronized across Chrome instances securely
  • Only accessible by the extension itself

URL Processing

  • Query Parameters: Now preserved to maintain functionality of shared links
  • Fragments Removed: Hash fragments (#section) are removed for cleaner sharing
  • Malicious URL Protection: Basic URL validation and error handling

Privacy Protection

  • No data collection or external analytics
  • All communication happens directly between your browser and Telegram
  • Minimal required permissions

🔧 Technical Implementation

URL Processing Algorithm

// Before: https://example.com/page?utm_source=social&ref=twitter#section1
// After:  https://example.com/page?utm_source=social&ref=twitter

function processUrl(url) {
  const urlObj = new URL(url);
  // Preserves: protocol, host, pathname, search (query parameters)
  // Removes: hash fragments (for cleaner sharing)
  return `${urlObj.protocol}//${urlObj.host}${urlObj.pathname}${urlObj.search}`;
}

Security Implementation

// Bot Token Encryption (Basic Obfuscation)
function encryptToken(token) {
  const salt = 'telegram-snapshare-v1';
  return btoa(salt + '|' + token); // Base64 encoding with salt
}

function decryptToken(encrypted) {
  const decoded = atob(encrypted);
  // Validates salt and extracts original token
  return decoded.substring(salt.length + 1);
}

Chrome Storage Structure

{
  "telegramBotToken": "dGVsZWdyYW0tc25hcHNoYXJlLXYxfDEyMzQ1Njo...", // Encrypted
  "telegramChatId": "@mychannel" // Plain text (not sensitive)
}

About

A Chrome extension that allows you to instantly share the current webpage to your Telegram channel or chat with an optional caption.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published