{"id":93,"date":"2019-11-14T01:01:23","date_gmt":"2019-11-14T00:01:23","guid":{"rendered":"https:\/\/blog.simon-frey.eu\/?p=93"},"modified":"2024-01-19T12:52:36","modified_gmt":"2024-01-19T11:52:36","slug":"tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users","status":"publish","type":"post","link":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/","title":{"rendered":"tor.js &#8211; Minimal JavaScript library to check if your visitors are TOR users"},"content":{"rendered":"\n<p><em>If you don&#8217;t know that yet. The <\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/www.torproject.org\/\" target=\"_blank\"><em>TOR browser<\/em><\/a><em> is a privacy protecting web browser defending you against tracking and surveillance and helps to circumvent censorship.<\/em><\/p>\n\n\n\n<p>Visiting the NYTimes via the TOR browser it annoyed me, that they are not automatically redirecting me to their .onion service.<\/p>\n\n\n\n<p>So I checked out, if it is possible to check if the person currently visiting your website is a TOR user and if so redirect them to your .onion address? As the TOR project offers a list with all currently active exit nodes, it was actually quite easy to build.<\/p>\n\n\n\n<p>This super small project downloads the list and checks if the IP of the current request is in that list. The generated JavaScript file contains a global variable telling if current visitor is using TOR.<\/p>\n\n\n\n<p>There are also a few convenient functions included, so you could archive the bespoken automatically redirect with 2 line of code. <\/p>\n\n\n\n<p>If you offer special services to TOR users or if you just wondering how many of your traffic come from TOR give this tiny library a go.<\/p>\n\n\n\n<p>The library documentation can be found on <a href=\"https:\/\/simon-frey.com\/torjs\/\">simon-frey.com\/torjs\/<\/a> and as the Project is Licensed Public Domain you are happily invited to host the PHP backend part yourself. Checkout the <a href=\"https:\/\/github.com\/simonfrey\/tor.js\">github repo<\/a> for more information on that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Show custom content to visitors of your page using TOR<\/p>\n","protected":false},"author":1,"featured_media":94,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[33],"tags":[5,64,23],"class_list":["post-93","post","type-post","status-publish","format-standard","hentry","category-project","tag-go","tag-privacy","tag-website"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>tor.js - Minimal JavaScript library to check if your visitors are TOR users - Blog by Simon Frey<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Simon Frey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"tor.js - Minimal JavaScript library to check if your visitors are TOR users - Blog by Simon Frey","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/","twitter_misc":{"Written by":"Simon Frey","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/#article","isPartOf":{"@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/"},"author":{"name":"Simon Frey","@id":"https:\/\/simon-frey.com\/blog\/#\/schema\/person\/34753982b648415636ee7a079f3e19a3"},"headline":"tor.js &#8211; Minimal JavaScript library to check if your visitors are TOR users","datePublished":"2019-11-14T00:01:23+00:00","dateModified":"2024-01-19T11:52:36+00:00","mainEntityOfPage":{"@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/"},"wordCount":232,"publisher":{"@id":"https:\/\/simon-frey.com\/blog\/#\/schema\/person\/34753982b648415636ee7a079f3e19a3"},"image":{"@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/#primaryimage"},"thumbnailUrl":"https:\/\/simon-frey.com\/blog\/wp-content\/uploads\/2019\/11\/DeepinScreenshot_select-area_20191114005148.png","keywords":["go","Privacy","website"],"articleSection":["Project"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/","url":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/","name":"tor.js - Minimal JavaScript library to check if your visitors are TOR users - Blog by Simon Frey","isPartOf":{"@id":"https:\/\/simon-frey.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/#primaryimage"},"image":{"@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/#primaryimage"},"thumbnailUrl":"https:\/\/simon-frey.com\/blog\/wp-content\/uploads\/2019\/11\/DeepinScreenshot_select-area_20191114005148.png","datePublished":"2019-11-14T00:01:23+00:00","dateModified":"2024-01-19T11:52:36+00:00","breadcrumb":{"@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/#primaryimage","url":"https:\/\/simon-frey.com\/blog\/wp-content\/uploads\/2019\/11\/DeepinScreenshot_select-area_20191114005148.png","contentUrl":"https:\/\/simon-frey.com\/blog\/wp-content\/uploads\/2019\/11\/DeepinScreenshot_select-area_20191114005148.png","width":693,"height":194,"caption":"tor.js JavaScript library webste screenshot"},{"@type":"BreadcrumbList","@id":"https:\/\/simon-frey.com\/blog\/tor-js-minimal-javascript-library-to-check-if-your-visitors-are-tor-users\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/simon-frey.com\/blog\/"},{"@type":"ListItem","position":2,"name":"tor.js &#8211; Minimal JavaScript library to check if your visitors are TOR users"}]},{"@type":"WebSite","@id":"https:\/\/simon-frey.com\/blog\/#website","url":"https:\/\/simon-frey.com\/blog\/","name":"Blog by Simon Frey","description":"","publisher":{"@id":"https:\/\/simon-frey.com\/blog\/#\/schema\/person\/34753982b648415636ee7a079f3e19a3"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/simon-frey.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/simon-frey.com\/blog\/#\/schema\/person\/34753982b648415636ee7a079f3e19a3","name":"Simon Frey","logo":{"@id":"https:\/\/simon-frey.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/simon-frey.com","https:\/\/www.linkedin.com\/in\/simonfrey\/","https:\/\/x.com\/eu_frey"]}]}},"_links":{"self":[{"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/comments?post=93"}],"version-history":[{"count":3,"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/posts\/93\/revisions"}],"predecessor-version":[{"id":177,"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/posts\/93\/revisions\/177"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/media\/94"}],"wp:attachment":[{"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/media?parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/categories?post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simon-frey.com\/blog\/wp-json\/wp\/v2\/tags?post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}