Move the Yes/No buttons into index.html; redirect options.html to it.

This commit is contained in:
David Fifield 2018-12-20 17:22:36 -07:00
parent 9e2a85d753
commit 627f37e004
4 changed files with 108 additions and 144 deletions

View file

@ -1,3 +1,4 @@
<Files "embed.html"> <Files "embed.html">
Header always unset X-Frame-Options Header always unset X-Frame-Options
</Files> </Files>
Redirect permanent /options.html /index.html

View file

@ -44,7 +44,7 @@
</style> </style>
</head> </head>
<body> <body>
<a target="_blank" href="options.html"> <a target="_blank" href="index.html">
<div id="badge"> <div id="badge">
Internet Freedom Internet Freedom
</div> </div>

View file

@ -17,6 +17,18 @@ textarea {
resize: none; resize: none;
padding: 1em; padding: 1em;
} }
#options {
background-color: rgba(0,0,0,0.8);
color: #fff;
resize: none;
position: relative; border: none;
width: 30rem;
padding: 3rem; margin: auto; margin-top: 1rem;
cursor: default;
}
#options .active {
color: #2F2 !important;
}
</style> </style>
</head> </head>
@ -29,6 +41,49 @@ textarea {
is a WebRTC pluggable transport for Tor. is a WebRTC pluggable transport for Tor.
</p> </p>
<p>
This page enables you to use your web browser as a proxy to help other
Internet users in censored places.
When you click yes, your browser will act as a
censorship circumvention proxy
as long as you are viewing a page with the snowflake badge.
</p>
<div id='options'>
<noscript>
<hr/>
Snowflake proxy requires javascript.
<br/>
To volunteer as a proxy, please enable javascript.
</noscript>
<div id='buttons' style='display:none'>
<p>
Do you want your browser to act as a proxy?
</p>
<p>
<button onclick="enableSnowflake()">
Yes
</button>
<button onclick="disableSnowflake()">
No
</button>
</p>
<div id="snowflake-status"></div>
</div>
<div id='cookies-disabled' style='display:none'>
<hr/>
<p>
Your browser has cookies disabled. You will need to enable them in order
to set Snowflake preferences.
</p>
</div>
</div>
<p> <p>
Minimum functionality has been achieved, and it is possible Minimum functionality has been achieved, and it is possible
to bootstrap a Tor client to 100% using Snowflake, and the to bootstrap a Tor client to 100% using Snowflake, and the
@ -74,5 +129,56 @@ gitweb.torproject.org/pluggable-transports/snowflake.git
<br/> <br/>
Last update: <time>2018-12-20</time> Last update: <time>2018-12-20</time>
<script>
// Defaults to opt-in.
var COOKIE_NAME = "snowflake-allow";
var COOKIE_LIFETIME = "Thu, 01 Jan 2038 00:00:00 GMT";
function readCookie(cookie) {
c = document.cookie.split('; ');
cookies = {};
for (i = 0 ; i < c.length ; i++) {
pair = c[i].split('=');
cookies[pair[0]] = pair[1];
}
return cookies[cookie];
}
function enableSnowflake() {
setSnowflakeCookie(1);
location.reload();
}
function disableSnowflake() {
setSnowflakeCookie(0);
location.reload();
}
function setSnowflakeCookie(val) {
document.cookie = COOKIE_NAME + "=" + val + ";path=/ ;expires=" + COOKIE_LIFETIME;
}
window.onload = function() {
if (navigator.cookieEnabled) {
// Both JS and cookies enabled -- display normal buttons.
document.getElementById('buttons').style = '';
} else {
// Display the cookies disabled message if necessary.
document.getElementById('cookies-disabled').style = '';
}
var enabled = readCookie(COOKIE_NAME);
var $status = document.getElementById('snowflake-status');
if ("1" === enabled) {
$status.innerHTML = 'Snowflake Proxy is ACTIVE <br/><br/>' +
'Thank you for contributing to internet freedom!';
$status.className = 'active';
} else {
$status.innerHTML = 'Snowflake Proxy is OFF';
$status.className = '';
}
}
</script>
</body> </body>
</html> </html>

View file

@ -1,143 +0,0 @@
<!doctype html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<title>Snowflake - Options</title>
<style>
* {
box-sizing: border-box;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
body {
position: absolute;
width: 100%; height: 100%; top: 0; margin: 0 auto;
background-color: #424;
color: #000;
font-size: 1rem;
text-align: center;
font-family: monospace;
background-image: url('koch.jpg');
}
.options {
background-color: rgba(0,0,0,0.8);
color: #fff;
resize: none;
position: relative; border: none;
width: 30rem; min-width: 40em;
padding: 3rem; margin: auto; margin-top: 1rem;
cursor: default;
}
a { color: #88F; } a:hover { color: #fff; }
#snowflake-status {
color: #888;
}
.active {
color: #2F2 !important;
}
</style>
</head>
<body>
<div class="options">
<h1>Snowflake Options</h1>
<p>
This page enables you to use your web browser as a proxy to help other
Internet users in censored places.
When you click yes, your browser will act as a
censorship circumvention proxy
as long as you are viewing a page with the snowflake badge.
</p>
<p>
For more information on this system click
<a href="https://snowflake.torproject.org/">here</a>.
</p>
<noscript>
<hr/>
Snowflake proxy requires javascript.
<br/>
To volunteer as a proxy, please enable javascript.
</noscript>
<div id='buttons' style='display:none'>
<p>
Do you want your browser to act as a proxy?
</p>
<p>
<button onclick="enableSnowflake()">
Yes
</button>
<button onclick="disableSnowflake()">
No
</button>
</p>
<div id="snowflake-status"></div>
</div>
<div id='cookies-disabled' style='display:none'>
<hr/>
<p>
Your browser has cookies disabled. You will need to enable them in order
to set Snowflake preferences.
</p>
</div>
<script>
// Defaults to opt-in.
var COOKIE_NAME = "snowflake-allow";
var COOKIE_LIFETIME = "Thu, 01 Jan 2038 00:00:00 GMT";
function readCookie(cookie) {
c = document.cookie.split('; ');
cookies = {};
for (i = 0 ; i < c.length ; i++) {
pair = c[i].split('=');
cookies[pair[0]] = pair[1];
}
return cookies[cookie];
}
function enableSnowflake() {
setSnowflakeCookie(1);
refreshStatus();
}
function disableSnowflake() {
setSnowflakeCookie(0);
refreshStatus();
}
function setSnowflakeCookie(val) {
document.cookie = COOKIE_NAME + "=" + val + ";path=/ ;expires=" + COOKIE_LIFETIME;
}
function refreshStatus() {
var enabled = readCookie(COOKIE_NAME);
var $status = document.getElementById('snowflake-status');
if ("1" === enabled) {
$status.innerHTML = 'Snowflake Proxy is ACTIVE <br/><br/>' +
'Thank you for contributing to internet freedom!';
$status.className = 'active';
} else {
$status.innerHTML = 'Snowflake Proxy is OFF';
$status.className = '';
}
}
window.onload = function() {
if (navigator.cookieEnabled) {
// Both JS and cookies enabled -- display normal buttons.
document.getElementById('buttons').style = '';
} else {
// Display the cookies disabled message if necessary.
document.getElementById('cookies-disabled').style = '';
}
refreshStatus();
}
</script>
</body>
</html>