A Chrome extension that bundles the day-to-day CloudFlare actions you need while browsing your site.
- One-click cache purge for the current tab
- "Allow My Access" button that detects your public IP and updates a pre-defined CloudFlare custom rule so you never lock yourself out
- "Block Access" toggle that disables the same rule when you want to revoke the exception
- Real-time status messaging in a clean popup UI
- Built on CloudFlare API v4
git clone <your-repository-url> cloudflare-tools
cd cloudflare-toolsCopy the example config file and add your credentials:
cp config.example.js config.jsThen edit config.js and replace the placeholder values with your actual CloudFlare credentials:
- zoneId: Your CloudFlare zone ID
- apiToken: Your CloudFlare API token (needs cache purge and ruleset permissions, see below)
- apiEndpoint: Update the zone ID in the URL to match your zone ID
- allowRuleDescription: The description text of the CloudFlare custom rule the extension should manage (defaults to
Allow my own Access) - ipLookupUrl: Optional public IP detection endpoint (defaults to
https://api.ipify.org?format=json)
The extension now reads and updates a custom firewall rule, so the token must include both cache and ruleset scopes. The following setup has been validated:
Required permissions
- Account WAF:Edit (covers all ruleset read/write actions needed for the Allow/Block flows)
- All zones → Cache Purge:Purge (needed for the primary cache purge feature)
IMPORTANT: The config.js file is excluded from version control to protect your credentials.
The extension requires icon files in three sizes (16x16, 48x48, 128x128). You can generate them from the included SVG:
npm install
npm run generate-iconsThis will create icon16.png, icon48.png, and icon128.png files.
Alternative: If you prefer, you can create your own icon files manually and name them accordingly.
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" (toggle in the top right corner)
- Click "Load unpacked"
- Select the
cloudflare-toolsdirectory - The extension should now appear in your extensions list as CloudFlare Tools
- Click the puzzle piece icon in Chrome's toolbar
- Find "CloudFlare Tools" in the list
- Click the pin icon to keep it visible in your toolbar
- Navigate to any URL on your CloudFlare-enabled website
- Click the CloudFlare Tools extension icon
- The popup will display the current URL
- Click the "Purge Cache" button
- Wait for the success message
- Click "Allow My Access" to detect your current public IP and update/enable the matching CloudFlare custom rule so you are always allowed through your firewall
- Use "Block Access" to temporarily disable that allow rule (useful when you want to remove the exception without editing CloudFlare manually)
The CloudFlare credentials are stored in config.js (which is excluded from version control):
- Zone ID: Your CloudFlare zone ID
- API Token: Your CloudFlare API token with cache purge and CloudFlare Ruleset permissions (see "Required CloudFlare token permissions")
- API Endpoint: The CloudFlare API URL (includes your zone ID)
- Zone ID: Found in your CloudFlare dashboard under the "API" section (this is the only credential you need besides the API token)
CloudFlare offers two types of API tokens. Choose the one that fits your needs:
Create a token associated with your user profile:
- Go to https://dash.cloudflare.com/profile/api-tokens
- Click "Create Token"
- Set permissions to include "Cache Purge"
- Save the token
Use this option when: You're using the extension personally and want the token tied to your user account.
Create a token at the account level:
- Go to your CloudFlare account settings
- Navigate to API Tokens under the account section
- Click "Create Token"
- Set permissions to include "Cache Purge"
- Save the token
Use this option when: You prefer service tokens that are not associated with individual users and your desired API endpoints are compatible. This is ideal for shared tools, automation, or when you want tokens that persist independently of user accounts.
- User API Tokens: Tied to your user profile, revoked if user access changes
- Account API Tokens: Not tied to individual users, better for service accounts and automation
To change your credentials, edit the config.js file and update the values in the CONFIG object.
IMPORTANT: Your credentials are now safely stored in config.js which is excluded from version control.
- The
config.jsfile is listed in.gitignoreand will NOT be committed to the repository - Only
config.example.js(with placeholder values) is tracked in version control - Never commit actual API tokens to a public repository
- The API token should be restricted to only have "Cache Purge" permissions in CloudFlare
manifest.json- Extension configurationpopup.html- Extension popup UIpopup.js- Cache purging logic and API integrationpopup.css- Stylingconfig.js- CloudFlare credentials (excluded from git, created from config.example.js)config.example.js- Template config file with placeholder values (tracked in git)icon.svg- Source icon file (vector format)generate-icons.js- Icon generation scriptpackage.json- Node.js dependencies.gitignore- Git ignore rules (excludes config.js, generated icons, and node_modules)README.md- This file
Extension won't load:
- Make sure all icon files are present (icon16.png, icon48.png, icon128.png)
- Verify that
config.jsexists (copy fromconfig.example.jsif missing)
Purge fails: Verify that:
- Your API token is valid and active
- The
config.jsfile has your correct credentials - The URL is part of your CloudFlare zone
- You have cache purge permissions for the zone
CONFIG is not defined error: Make sure config.js exists and is loaded before popup.js in popup.html
CORS errors: The extension has proper permissions set in manifest.json for the CloudFlare API
- Node.js and npm (for generating icons)
- Git
- Google Chrome browser
- Make your changes to the source files
- Test the extension by reloading it in Chrome (
chrome://extensions/> Reload button) - If you modify
icon.svg, regenerate the PNG icons:npm run generate-icons
The following files are excluded from version control (.gitignore):
config.js- Contains your actual credentials (must be created fromconfig.example.js)- Generated icon PNG files -
icon16.png,icon48.png,icon128.png node_modules/directory
After cloning the repository, you must:
- Create
config.jsfromconfig.example.jsand add your credentials - Run
npm installandnpm run generate-iconsto create the icon files
When contributing to this project:
- Create a new branch for your feature/fix
- Make your changes
- Test thoroughly in Chrome
- Commit your changes with clear commit messages
- Push and create a pull request
Remember: Never commit actual API tokens or sensitive credentials to the repository.
This project is open source and available for personal and commercial use.