Miscellany
Miscellaneous pieces of information:
Contents
- Simple ad-blocking browser extension (Google Chrome)
- Decode Wikipedia URLs containing special characters
Simple ad-blocking browser extension (Google Chrome)
Blocks advertisement / promotion sections in the Amazon shopping cart (more than ten years of being force-fed a "special" credit card offer is enough).
It is probably easily ported to Mozilla Firefox (or as user script with the GreaseMonkey extension)
Here's how to make such an extension:
- Find the ids of the HTML elements that should be blocked (Note that not every element has one as this depends on the site):
Chrome: RMB, Inspect. - Create two files in a new directory (e.g. "myextension")
- content.js
This is the JavaScript that will run when the page is loaded, allowing to modify it.
Specifically, it sets all unwanted elements in the Array to invisible:var hide = [ "sc-new-upsell", // e.g. credit card "sc-rec-right", // often bought together... "sc-rec-bottom", // customers that bought .. also bought .. "rhf" // recently viewed and recommendations ]; for (id of hide){ document.getElementById(id).style.display = "none"; }
So this loops over the Array of ids, finds each element in the page and hides it by setting its "display" property to "none". - manifest.json
This file describes the extension and specifies on which domains it is allowed to run.
It is limited to Amazon domains and only active when the URL contains the "gp/cart" part.{ "manifest_version": 2, "name": "Amazon shopping cart ad blocker ", "description": "Hides several advertisement / promotion sections on Amazon's shopping cart page (com, de, co.uk, fr, es, it, nl, ca, com.br, com.au, cn, in, co.jp).", "version": "0.1", "content_scripts": [ { "matches": [ "https://www.amazon.com/gp/cart/*", "https://www.amazon.de/gp/cart/*", "https://www.amazon.co.uk/gp/cart/*", "https://www.amazon.fr/gp/cart/*", "https://www.amazon.es/gp/cart/*", "https://www.amazon.it/gp/cart/*", "https://www.amazon.ca/gp/cart/*", "https://www.amazon.com.br/gp/cart/*", "https://www.amazon.com.au/gp/cart/*", "https://www.amazon.cn/gp/cart/*", "https://www.amazon.in/gp/cart/*", "https://www.amazon.co.jp/gp/cart/*", "https://www.amazon.com.mx/gp/cart/*", "https://www.amazon.nl/gp/cart/*" ], "js": ["content.js"] } ], "permissions": [ "https://*.amazon.com/", "https://*.amazon.de/", "https://*.amazon.co.uk/", "https://*.amazon.fr/", "https://*.amazon.es/", "https://*.amazon.it/", "https://*.amazon.ca/", "https://*.amazon.com.br/", "https://*.amazon.com.au/", "https://*.amazon.cn/", "https://*.amazon.in/", "https://*.amazon.co.jp/", "https://*.amazon.com.mx/", "https://*.amazon.nl/" ] }
- content.js
- Load the custom extension
- Copy, paste and open chrome://extensions (the link does not work). Or use Menu>More tools>Extensions
- Check "Developer mode" to enable (shows some buttons below)
- Click "Load unpacked extension..." and browse to the directory containing the two files
- You now can disable "Developer mode" again by unchecking.
"Pack extension" allows packaging the extension in "<directory>" into a ZIP file with the name "<directory>.crx" and a key file "<directory>.pem" that is used for publishing the extension (keep it private).
- Copy, paste and open chrome://extensions (the link does not work). Or use Menu>More tools>Extensions
That's it. Or just download the file here (no warranty, just unpack as ZIP to verify contents). To add the extension to Chrome, drag it from a file manager (e.g. Windows Explorer) into the browser.
Decode Wikipedia URLs
Wikipedia's software MediaWiki uses a custom URL (a kind of URI) encoding for page references, e.g. https://en.wikipedia.org/wiki/%C3%96#.C3.96_in_other_languages, where special, i.e. non-ASCII characters are replaced with the two UTF-8 hexadecimal values marked with a leading percentage or period (full stop) character (Ö character info on https://en.wikipedia.org/wiki/Ö or http://graphemica.com/Ö).
The percentage notation is the standard URL escape sequence (URL or percent encoding).
The second just seems to replace the '%' with a '.', so decoding it to make it readable is simple. So is replacing the underscores with spaces.
Just paste a Wikipedia URL into the text field below and it will create a clickable and readable link from it.
Link: