Skip to content

Instantly share code, notes, and snippets.

@sputnick-dev
Last active August 22, 2016 21:13
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 sputnick-dev/1f9a306143fb9bfaab999bc3c043a55b to your computer and use it in GitHub Desktop.
Save sputnick-dev/1f9a306143fb9bfaab999bc3c043a55b to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name alert_on_non_ascii_url
// @namespace sputnick
// @include https://*
// @include http://*
// @version 2
// @grant none
// @run-at document-start
// ==/UserScript==
var hasMoreThanAscii = document.location.href
.split("")
.some(function(char) { return char.charCodeAt(0) > 127;});
// FF chrome
if (hasMoreThanAscii || /^https?:\/\/xn--/.test(document.location.href))
alert(document.location.href+ " have non ASCII characters in URL."+
"\nAre you sure this is not a phishing (Pascal-trap©®™) ?!"+
"\nClose the tab in case of doubt...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment