/ Published in: JavaScript
                    
                                        
When you're viewing an older version of a snippet, the Plain Text and Highlighted Text links point back to the latest version.  This greasemonkey script fixes those links to point to the version you're currently viewing.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
// ==UserScript==
// @name Fix Snippet's Plain/Highlighted Text link
// @author Andy Harrison
// @namespace http://dragonzreef.com/greasemonkey/snipplr_plainhighlighted.user.js
// @description When viewing a snippet, fixes the Plain/Highligted Text link to go to the version you're looking at instead of the latest version.
// @include http://snipplr.com/view*
// ==/UserScript==
window.addEventListener("load", function()
{
var viewbar = document.getElementById("viewsource");
if(!viewbar) return;
var a = viewbar.getElementsByTagName("a");
for(var i=0; i<a.length; i++)
{
if(a[i].innerHTML == "Plain Text")
{
a[i].href += document.location.href.replace(/^http:\/\/snipplr.com\/view\/\d+(\.\d+).*$|.*/,"$1");
return;
}
else if(a[i].innerHTML == "Highlighted Text")
{
var vers = document.location.href.replace(/^http:\/\/snipplr.com\/view.php\?([^#]*&)*?id=\d+(\.\d+).*$|.*/,"$2");
a[i].href = a[i].href.replace(/^(http:\/\/snipplr.com\/view\/\d+)(.*)$/, "$1"+vers+"$2");
return;
}
}
}, false);
Comments
 Subscribe to comments
                    Subscribe to comments
                
                