Decode URLs from The Great Suspender after a browser restart fails to reload them
Posted by jpluimers on 2017/03/16
Hosted at: Decode URLs from The Great Suspender after a browser restart fails to reload them
Converts URLs like these:
chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#url=http%3A%2F%2Fwww.barryodonovan.com%2F2012%2F06%2F29%2Fmigrating-svn-with-branches-and-tags-to-git
back into
http://www.barryodonovan.com/2012/06/29/migrating-svn-with-branches-and-tags-to-git
Source below.
It decodes a URL encoded by The Great Suspender which is a cool Google Chrome plugin that suspends pages after some idle time.
The uncool thing is that when Google Crome restarts after a crash (it’s software, it does that, especially as it consumes truckloads of memory and is full of memory leaks) it often fails to restore some (but not many) of the suspended pages into a usable state: it shows only the encoded URLs.
–jeroen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <!– | |
| Resurrect | |
| Based on 20160531-Google-Plus–403.-That’s-an-error.–Your-client-does-not-have-permission-to-get-URL–sorry–IndexRedirect–workaround.html | |
| at https://gist.github.com/jpluimers/4f07a2f3f9b9890a3a44e184c1abadf2 | |
| Converts URLs like these: | |
| chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#url=http%3A%2F%2Fwww.barryodonovan.com%2F2012%2F06%2F29%2Fmigrating-svn-with-branches-and-tags-to-git | |
| back into | |
| url=http://www.barryodonovan.com/2012/06/29/migrating-svn-with-branches-and-tags-to-git | |
| The Great Suspender Google Extension: | |
| https://chrome.google.com/webstore/detail/the-great-suspender/klbibkeccnjlkjkiokjodocebajanakg | |
| Test at http://jsbin.com/yukidaferu/1/edit?html,console,output | |
| –> | |
| <html> | |
| <title>Decode URLs from The Great Suspender after a browser restart fails to reload them</title> | |
| <body> | |
| <h1>Decode URLs from The Great Suspender after a browser restart fails to reload them</h1> | |
| <p>Please URL encoded by <a href="https://github.com/deanoemcke/thegreatsuspender" target="_blank">The Great Suspender</a>:</p> | |
| <input id="suspenderUrl" size="200"> | |
| <button type="button" onclick="decodeSuspenderUrlMethod()">Submit</button> | |
| <div id="decodedUrlsCaptionDiv"> | |
| <p id="decodedUrlsCaption">Here you will see the decoded URLs so you can follow them:</p> | |
| </div> | |
| <ul id="decodedUrlsUl"> | |
| </ul> | |
| <script> | |
| // based on http://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_validate | |
| function decodeSuspenderUrlMethod() { | |
| var decodedUrl = ""; | |
| var errorText = ""; | |
| // Get the value of the input field with id="numb" | |
| var suspenderUrl = document.getElementById("suspenderUrl").value; | |
| var stripPrefix = "chrome-extension://klbibkeccnjlkjkiokjodocebajanakg/suspended.html#url="; | |
| var prefix = stripPrefix + "http"; | |
| // Am I a SO developer now? At least I'm quickly learning some JavaScript basics… | |
| // http://stackoverflow.com/questions/1767246/check-if-string-begins-with-something/9430330#9430330 | |
| // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/substring | |
| if (suspenderUrl.indexOf(prefix) == 0) { | |
| // now strip the bits we don't need, then decode what is left. | |
| // I always wondered why they call it substring instead of subString | |
| var googlePlusEncodedUrl = suspenderUrl.substring(stripPrefix.length); | |
| // decoding got a new new a while ago: http://stackoverflow.com/questions/4292914/javascript-url-decode-function/4292961#4292961 | |
| decodedUrl = decodeURIComponent(googlePlusEncodedUrl); | |
| } else { | |
| errorText = "URL is missing this prefix: <<" + prefix + ">>"; | |
| }; | |
| // for now, just add the output; in the future, only add unique output. | |
| // Based on http://stackoverflow.com/questions/5519747/how-to-add-anchor-tags-dynamically-to-a-div-in-javascript/5519795#5519795 | |
| var decodedUrlsUl = document.getElementById("decodedUrlsUl"); | |
| var decodedUrlLi = document.createElement('li'); | |
| if (errorText == ""){ | |
| var aTag = document.createElement('a'); | |
| aTag.setAttribute('href', decodedUrl); | |
| aTag.innerHTML = decodedUrl; | |
| decodedUrlLi.appendChild(aTag); | |
| } else { | |
| var aDiv = document.createElement('div'); | |
| aDiv.innerHTML = errorText + " " + suspenderUrl; | |
| decodedUrlLi.appendChild(aDiv); | |
| } | |
| decodedUrlsUl.appendChild(decodedUrlLi); | |
| } | |
| </script> | |
| </body> | |
| </html> |






Leave a comment