Skip to content

Instantly share code, notes, and snippets.

@dubrox
Created August 3, 2022 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dubrox/187f50dba68b707be302ae83f7aabec6 to your computer and use it in GitHub Desktop.
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.
// ==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