I need to give the various solutions here some thought: [Wayback/Archive] Shortcut to open specific bookmark / URL in Chrome – Super User
–jeroen
Posted by jpluimers on 2023/06/12
I need to give the various solutions here some thought: [Wayback/Archive] Shortcut to open specific bookmark / URL in Chrome – Super User
–jeroen
Posted in Chrome, Firefox, Power User, Web Browsers | Leave a Comment »
Posted by jpluimers on 2023/06/09
The Bookmarklets posts have mostly reached past the front of the blog queue, so here goes a tweet from last year:
[Archive] Jeroen Wiert Pluimers on Twitter: “The past week, I learned a ton of HTML, JavaScript and (Shadow) DOM oddities while writing browser bookmarklets to speed up my blogging and @waybackmachine / @archiveis archiving. There is always an XKCD: «xkcd: Is It Worth the Time?» …” / Twitter
–jeroen
Posted in Bookmarklet, Fun, LifeHacker, Power User, Web Browsers, xkcd | Leave a Comment »
Posted by jpluimers on 2023/06/08
In Bookmarklets for Archive.is and the WayBack Machine to go to the original page, I wrote about how the Shadow DOM is used to prevent side effects between the code of the WayBack machine and the archived page.
In a similar manner, Bookmarklets can also interfere with code on the page and vice versa, for instance by using global variables.
That is why the [Wayback/Archive] A simple bookmarklet to tweet the current page – DEV Community is wrapped in a special kind of function:
javascript:(function(){ n=getSelection().anchorNode; t=n.nodeType===3?n.data:n.innerText;t='“'+t+'”\\n\\n'; window.open(`https://twitter.com/intent/tweet? text=${encodeURIComponent(t)}${document.location.href}`) })()
This is an [Wayback/Archive] IIFE – MDN Web Docs Glossary: Definitions of Web-related terms | MDN or “Immediately Invoked Function Expression”, a mechanism coined by [Archive] Ben Alman (@cowboy) / Twitter at [Wayback/Archive] Ben Alman » Immediately-Invoked Function Expression (IIFE).
Since the variables are inside the function body, they won’t interfere with the page. The body will be immediately executed.
Related:
–jeroen
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »
Posted by jpluimers on 2023/06/07
Quite often, when browsing an archived page on Archive.is or the WayBack Machine, I want to check the current status of the original page.
So I wrote a few Bookmarklets.
Any Archive.is page has a Saved from field which is an input html element having a name attribute with value q and a value property containing the URL, which is navigated to by assigning the location in the above code.
So my goto Bookmarklet is this one:
javascript:open(document.getElementsByName("q")[0]?.value)
It uses [0]? as there is no getElementsByName, but there is [Wayback/Archive] Document.getElementsByName() – Web APIs | MDN as name values need not to be unique but id values have to be.
The above works on all types of Archive.is page types:
Saved from field.Saved from and Redirected from fields.Saved from and Redirected from, the fields Via and Original also are added.To get the additional fields from the other fields, we need to figure out a way to access them.
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | 1 Comment »
Posted by jpluimers on 2023/06/01
As Chrome mangles Bookmarklets to a partially escaped form (I think using Percent encoding), I first tried to document my Bookmarklets in Markdown so I could easier edit them and copy these JavaScript links to various browsers. That failed, because the html rendered from the Markdown didn’t contain the links any more. So I now use plain html for documenting them which is a pain to edit but works.
[Wayback/Archive] Some bookmarklets hosted as [Wayback/Archive] Some bookmarklets – cached 1 minute – throttled and [Wayback/Archive] Some bookmarklets – cached 1 year – CDN.
This is why:
Searches: [Wayback/Archive] markdown javascript in link – Google Search and [Wayback/Archive] “embed javascript” in markdown – Google Search.
–jeroen
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »
Posted by jpluimers on 2023/05/31
Quite often while saving a URL in the WayBack Machine, the response often is headed “Sorry” with non-descriptive “Job failed”. In the background however, at least half of th…
Related: JavaScript bookmarklet to replace part of the WayBack machine URL
For instance, a while ago for instance http://archive.fo/search/?q=nu.nl, https://archive.fo/search/?q=nu.nl and similar URLs redirected to https://archive.li/search/?q=nu.nl, which in turn redirected to itself:
This page isn’t working
archive.li redirected you too many times.
ERR_TOO_MANY_REDIRECTS
This isn’t a cookie thing as it happens in an anonymous window on several browsers as well. Most redirect checkers return a 429, as Archive Today has quite strict rate limiting:
https://archive.fo/search/?q=nu.nlhttps://archive.fo/search/?q=nu.nlI tried these bookmarklets to go to a good archive.is link from the above replacing http://archive.fo/search/?q=nu.nl, https://archive.fo/search/?q=nu.nl, http://archive.li/search/?q=nu.nl and https://archive.li/search/?q=nu.nl with https://archive.is/search/?q=nu.nl (with the same above bolded parts):
javascript:(function() {window.location=window.location.toString().replace(/^http.?:\/\/archive\.[is|li]\//,'https://archive.is/');})()
It can even be simpler (but maybe not fully conformant to specs):
javascript:location=location.href.replace(/^http.?:\/\/archive\.[is|li]\//,'https://archive.is/')
These both fail!
Even a simple bookmarklet like this fails too:
javascript:alert('hello world!');
It took me a bit of thinking to figure out why, but then figured out that any JavaScript requires a page context to run, and when no page is displayed, there is no context to run on.
And indeed:
–jeroen
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »
Posted by jpluimers on 2023/05/23
Quite often while saving a URL in the WayBack Machine, the response often is headed “Sorry” with non-descriptive “Job failed”.
In the background however, at least half of those times the job actually succeeded.
Some periodes that success rate was way lower as the archival job didn’t start with a GET request. The workaround was to use a POST request, see I want to check out how to do POST requests using bookmarklets in order to save URLs to the WayBack machine and [Archive] Jeroen Wiert Pluimers on Twitter: “Does anyone why the @waybackmachine has a lot of job failed and 404 errors over the last few days? … and … just returned a 404; most of my archivals the last few days failed or had to be retried at least half a dozen times to succeed. …” / Twitter
The error message in both “Job failed” cases is the same, so it makes sense to differ between the first case (job started and complete, but web interface failed to get that) and the latter (job didn’t even start) by doing the below URL replacement with a bookmarklet:
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »
Posted by jpluimers on 2023/05/16
Saved because I want to learn how to save a YouTube URL into a [Wayback/Archive] YouTube: Watch later play list, as doing it by hand takes at least 10 seconds per URL.
[Wayback/Archive] Bookmarklet-Youtube: Add all subscriptions to watch-later
–jeroen
Posted in Bookmarklet, Development, GoogleBookmarks, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers | Leave a Comment »
Posted by jpluimers on 2023/05/04
As a continuation of the various bookmarklet posts, here is one with information on bookmarklets that operate on the current page, for instance when you already got text selected.
Bookmarklets
Bookmarklets are free tools to help with repetitive or otherwise impossible tasks in your web browser. To use a bookmarklet from this site on another web page:
1. Drag the bookmarklet (e.g. zoom images in or zap colors) to your [Wayback/Archive] Bookmarks Toolbar or Links Bar.
2. While viewing a page you want to use the bookmarklet on, click the bookmarklet from your Bookmarks Toolbar.Bookmarklet categories:
- [Wayback/Archive] Link Bookmarklets: search links, linked images, etc.
- [Wayback/Archive] Form Bookmarklets: toggle checkboxes, enlarge textareas, view passwords, etc.
- [Wayback/Archive] Text and Data Bookmarklets: zoom images in, sort table, etc.
- [Wayback/Archive] Zap Bookmarklets: get rid of annoyances such as unreadable color combinations, Flash, and blind links.
- [Wayback/Archive] Web Development Bookmarklets: debug web pages and experiment with new code.
- [Wayback/Archive] Validation Bookmarklets: check how well the code of a web page is written.
- [Wayback/Archive] Miscellaneous Bookmarklets.
- [Wayback/Archive] Search Bookmarklets.
- [Wayback/Archive] Search Engine Optimization Bookmarklets: search for backlinks, analyze search engine positions.
- [Wayback/Archive] Log Analysis Bookmarklets: analyze referer logs efficiently.
- [Wayback/Archive] Flash Bookmarklets: pause, rewind, and fast-forward Flash cartoons.
- [Wayback/Archive] Tipping Bookmarklet: send money to an e-mail address in a page.
- [Wayback/Archive] Color Bookmarklets: change all colors on a page at once.
- [Wayback/Archive] Keyword Bookmarklets for Scripters: type “jb document.body” to make document.body blink, etc.
- [Wayback/Archive] Site-specific Bookmarklets: fix annoyances on some sites I read.
- [Wayback/Archive] Bugzilla Bookmarklets: for people involved in the [Wayback/Archive] Mozilla project or other projects that track bugs using [Wayback/Archive] Bugzillas.
- [Wayback/Archive] Testing browsers: test features or stress limits of browsers.
Other pages:
- [Wayback/Archive] Frequently asked questions
- [Wayback/Archive] Announcement list
- [Wayback/Archive] Links
- [Wayback/Archive] Browser comparison chart: how well various browsers support bookmarklets.
- [Wayback/Archive] Add a bunch of bookmarklets at once
- [Wayback/Archive] Creating a remote control bookmarklet
All via [Wayback/Archive] bookmarklet that works on link of current selection – Google Search
–jeroen
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers, Web Development | Leave a Comment »
Posted by jpluimers on 2023/04/27
I want to check out how to do POST requests using bookmarklets in order to save URLs to the Wayback machine.
The reason is that every few months or so, saving a page the normal way through a something like https://web.archive.org/save/URL fails for one reason or the other, but going to https://web.archive.org/save, then entering URL, and pressing “SAVE PAGE” button works fine:
job failed and 404 errors over the last few days? … and … just returned a 404; most of my archivals the last few days failed or had to be retried at least half a dozen times to succeed. …” / TwitterThe the failing way above is using a GET request, the succeeding workaround will open https://web.archive.org/save/URL using the below POST request (where I omitted some HTTP cookies and HTTP header fields for brevity).
PowerShell:$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession $session.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36" Invoke-WebRequest -UseBasicParsing -Uri "https://web.archive.org/save/URL" ` -Method "POST" ` -WebSession $session ` -Headers @{ "method"="POST" "origin"="https://web.archive.org" "referer"="https://web.archive.org/save" } ` -ContentType "application/x-www-form-urlencoded" ` -Body "url=URL&capture_outlinks=on&capture_all=on&capture_screenshot=on"
bash:curl 'https://web.archive.org/save/URL' \ -H 'origin: https://web.archive.org' \ -H 'content-type: application/x-www-form-urlencoded' \ -H 'referer: https://web.archive.org/save' \ --data-raw 'url=URL&capture_outlinks=on&capture_all=on&capture_screenshot=on' \ --compressed
fetch("https://web.archive.org/save/URL", { "headers": { "content-type": "application/x-www-form-urlencoded", }, "referrer": "https://web.archive.org/save", "body": "url=URL&capture_outlinks=on&capture_all=on&capture_screenshot=on", "method": "POST", "mode": "cors" });
BTW: Yes, I know that URL is not a valid URL, so it will return a page with “http://url/ URL syntax is not valid.“.
All links below via [Wayback/Archive] bookmarklet post request – Google Search:
I tried to put createFormSubmittingBookmarklets/createFormSubmitBookmarklets.js in a bookmarklet using both userjs.up.seesaa.net/js/bookmarklet.html and skalman.github.io/UglifyJS-online. That failed: somehow this code does not want to run as bookmarklet.
Running it from the console is fine though, and gave me this basic bookmarklet template:
javascript:function sf(ur,ty,fd){function me(tg,pr){var el=document.createElement(tg);for(const[nm,vl]of Object.entries(pr)){el.setAttribute(nm,vl);}return el}const fm=me("form",{action:ur,method:ty,style:"display:hidden;"});for(const[nm,vl]of Object.entries(fd)){fm.appendChild(me("input",{name:nm, value:vl}))}document.body.appendChild(fm);fm.submit()}sf("https://web.archive.org/save","post",{"url":"URL","capture_outlinks":"on","capture_all":"on","capture_screenshot":"on","wm-save-mywebarchive":"on","email_result":"on","":"SAVE PAGE"});
There bold URL there is the URL to be saved. I need to test this, then rework it to become parameterised.
–jeroen
Posted in Bookmarklet, Development, JavaScript/ECMAScript, Power User, Scripting, Software Development, Web Browsers, Web Development | Leave a Comment »