pastebin / pastebin.com embeds is no longer working on thecoli and I haven't seen an update by the xenforo team or the dev that does the media plugin.
when you see
---
404 Not Found
nginx
---
it's not necessarily because the file doesn't exist but because pastebin changed their embed url path from
https://pastebin.com/embed_iframe.php?i=KiHTG5PG to
https://pastebin.com/embed_js/KiHTG5PG
the bookmarklet and userscript below fixes it.
- Problem: Old Pastebin iframe URLs (embed_iframe.php) return 404 errors; new URLs use embed_js/ or embed_iframe/.
- Solution: A bookmarklet to dynamically update iframe src attributes on a webpage.
High-Level Overview
The task is to explain what the bookmarklet and userscript do on XenForo-compatible forum sites and provide their latest optimized versions without comments. I’ll then append a detailed, simple summary of their functionality.
Scope
- Problem: Clarify the behavior of the bookmarklet (artifact_id: d1883ab9-de8c-4f43-98cd-717f926400e1, v7) and userscript (artifact_id: 6d25402a-f082-4c33-9df8-a48561c37039, v3) on XenForo forums.
- Solution: Provide code without comments and a plain-language summary.
- Constraints: Maintain prior optimizations (throttling, toast reuse), target XenForo compatibility.
Memory Log
- Prior interactions:
- Bookmarklet: Evolved from URL fixes to span-priority with optimizations.
- Userscript: Mirrored bookmarklet, targeted XenForo threads.
- Last update: Fixed CPU/memory issues with throttling and toast reuse.
- Current request: Explain XenForo behavior, show code, add summary.
Bookmarklet (Without Comments)
Pastebin URL Fix Bookmarklet (Optimized)
pastebin.com/AymATXhw
Userscript
pastebin.com/gY50EbkU
Detailed Summary in Simple Terms
What They Do on XenForo-Compatible Forum Sites
The bookmarklet and userscript are tools designed to fix broken Pastebin links on XenForo forum sites (like xenforo.com/community/threads/* or any site with URLs like example.com/threads/*). These forums often let users embed Pastebin code snippets (e.g., for sharing scripts or text) into posts. However, older Pastebin embeds might use an outdated link format (embed_iframe.php) that no longer works properly, causing the embedded content to fail to load or display incorrectly. The bookmarklet and userscript step in to update these links to a modern, working format (embed_js/) and ensure the content shows up as intended.
Here’s how they work in simple steps:
- Finding Pastebin Embeds:
- They first look for special <span> tags on the page that XenForo uses to mark Pastebin embeds. These tags hold information about the embed, like the Pastebin ID (e.g., B3aH8ynE), stored in a data-s9e-mediaembed-iframe attribute.
- If no unprocessed spans are found, they check for existing <iframe> tags with the old embed_iframe.php format as a backup.
- Updating the Links:
- For spans, they read the stored data, pull out the Pastebin ID, and create a new <iframe> with the updated link (
https://pastebin.com/embed_js/[Pastebin ID]). This new iframe replaces the span.
- For existing iframes, they take the old link, extract the Pastebin ID, and update the src attribute to the new format.
- If the new embed_js/ link fails (e.g., due to site restrictions), they switch it to embed_iframe/ as a fallback.
- Showing Feedback:
- A small pop-up message (called a "toast") appears in the bottom-right corner of the screen. It tells you how many embeds were fixed (e.g., "Updated 2 Pastebin embeds") or if none were found ("No outdated Pastebin embeds found").
- The toast fades in, stays for 3 seconds, then fades out and disappears.
- Keeping Up with Changes:
- The tools don’t just run once—they keep watching the page. If new Pastebin embeds appear (e.g., when you scroll and more posts load), they automatically update those too. To avoid slowing down your browser, they wait half a second between checks.
- Avoiding Duplicates:
- They mark each span or iframe they process with a data-processed tag so they don’t keep redoing the same ones, which saves time and resources.
Why They’re Useful
- Fixes Broken Content: Old Pastebin embeds might not load, leaving blank spaces or errors in forum posts. These tools make sure you can see the code or text someone shared.
- Works Automatically (Userscript): On XenForo sites, the userscript runs by itself when you load a thread page—no need to click anything.
- One-Click Fix (Bookmarklet): For any page (not just XenForo), you can click the bookmarklet to fix embeds instantly.
- Handles New Stuff: If a forum loads more posts as you scroll, the tools catch those new embeds too.
How They’re Optimized
- Low Impact: They’re designed to use less of your computer’s power. The watching feature waits between checks, and they reuse the same toast message instead of making new ones every time.
- Error Handling: If something goes wrong (e.g., a weird span format), they show a toast like "Error parsing span data" and move on without crashing.
- Smart Fallback: If the modern link format doesn’t work, they try the older one to keep things working.
Example Scenario
Imagine you’re on a XenForo thread where someone posted a script using a Pastebin embed. The embed shows as a blank box because it’s using the old embed_iframe.php link. You run the bookmarklet (or the userscript does it automatically), and:
- It finds the span or iframe, grabs the Pastebin ID (e.g., edy4B8du).
- Updates it to
https://pastebin.com/embed_js/edy4B8du.
- Replaces or updates the embed, and the script appears in a neat box.
- A toast pops up saying "Updated 1 Pastebin embed."
Limitations
- They only fix Pastebin embeds with valid IDs (at least 8 characters long).
- They might miss embeds if XenForo uses a totally different format they don’t recognize.
- On very busy pages with tons of changes, they might still use some CPU, but much less than before.
In short, these tools make sure Pastebin embeds on XenForo forums work again by updating old links, showing you what’s happening with toasts, and keeping an eye out for new embeds—all while being efficient and easy to use.