Created
August 3, 2022 18:34
-
-
Save dubrox/187f50dba68b707be302ae83f7aabec6 to your computer and use it in GitHub Desktop.
Tampermonkey script to quickly check the visa requirements of a selected passport for each country on the Passport Index website, by simply clicking on the country in the map.
This file contains 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
// ==UserScript== | |
// @name Passport Index clickable map | |
// @namespace dubrox.com | |
// @version 0.1 | |
// @description Tampermonkey script to quickly check the visa requirements of a selected passport for each country on the Passport Index website, by simply clicking on the country in the map. | |
// @author dubrox | |
// @match https://www.passportindex.org/passport/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=passportindex.org | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const countryLabelToNameMap = { | |
"Lao People's Democratic Republic": "Laos", | |
"Vietnam": "Viet Nam", | |
}; | |
const countryNameFix = (label) => countryLabelToNameMap.hasOwnProperty(label) ? countryLabelToNameMap[label] : label; | |
const bind = () => { | |
// avoid binding attempts while the map regions are still not loaded | |
if (!document.querySelector('#vmap svg')) return setTimeout(bind, 1000); | |
const regionPathNodes = document.querySelectorAll('.jqvmap-region'); | |
const labelNode = document.querySelector('.jqvmap-label'); | |
const searchNode = document.getElementById('countrysearch'); | |
regionPathNodes.forEach(i => i.addEventListener('click', () => { | |
const countryLabel = labelNode.textContent; | |
const countryName = countryNameFix(countryLabel); | |
searchNode.value = countryName; | |
countrysearch(); // function from the Passport Index page. | |
})); | |
} | |
bind(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment