Ticket #25722: 0001-Move-the-Yes-No-buttons-into-index.html-redirect-opt.patch

File 0001-Move-the-Yes-No-buttons-into-index.html-redirect-opt.patch, 7.8 KB (added by dcf, 7 months ago)
  • proxy/static/.htaccess

    From 627f37e00485fc87b790418f7edba8fb0c7bfd28 Mon Sep 17 00:00:00 2001
    From: David Fifield <david@bamsoftware.com>
    Date: Thu, 20 Dec 2018 17:22:36 -0700
    Subject: [PATCH] Move the Yes/No buttons into index.html; redirect
     options.html to it.
    
    ---
     proxy/static/.htaccess    |   1 +
     proxy/static/embed.html   |   2 +-
     proxy/static/index.html   | 106 ++++++++++++++++++++++++++++++++++
     proxy/static/options.html | 143 ----------------------------------------------
     4 files changed, 108 insertions(+), 144 deletions(-)
     delete mode 100644 proxy/static/options.html
    
    diff --git a/proxy/static/.htaccess b/proxy/static/.htaccess
    index f733194..3dd217d 100644
    a b  
    11<Files "embed.html">
    22    Header always unset X-Frame-Options
    33</Files>
     4Redirect permanent /options.html /index.html
  • proxy/static/embed.html

    diff --git a/proxy/static/embed.html b/proxy/static/embed.html
    index 65303b5..9efe369 100644
    a b  
    4444  </style>
    4545</head>
    4646<body>
    47   <a target="_blank" href="options.html">
     47  <a target="_blank" href="index.html">
    4848    <div id="badge">
    4949      Internet Freedom
    5050    </div>
  • proxy/static/index.html

    diff --git a/proxy/static/index.html b/proxy/static/index.html
    index 74779e5..cfe8d89 100644
    a b textarea { 
    1717  resize: none;
    1818  padding: 1em;
    1919}
     20#options {
     21  background-color: rgba(0,0,0,0.8);
     22  color: #fff;
     23  resize: none;
     24  position: relative; border: none;
     25  width: 30rem;
     26  padding: 3rem; margin: auto; margin-top: 1rem;
     27  cursor: default;
     28}
     29#options .active {
     30  color: #2F2 !important;
     31}
    2032</style>
    2133</head>
    2234
    is a WebRTC pluggable transport for Tor. 
    3042</p>
    3143
    3244<p>
     45This page enables you to use your web browser as a proxy to help other
     46Internet users in censored places.
     47When you click yes, your browser will act as a
     48censorship circumvention proxy
     49as long as you are viewing a page with the snowflake badge.
     50</p>
     51
     52<div id='options'>
     53
     54<noscript>
     55<hr/>
     56Snowflake proxy requires javascript.
     57<br/>
     58To volunteer as a proxy, please enable javascript.
     59</noscript>
     60
     61<div id='buttons' style='display:none'>
     62<p>
     63Do you want your browser to act as a proxy?
     64</p>
     65
     66<p>
     67<button onclick="enableSnowflake()">
     68  Yes
     69</button>
     70<button onclick="disableSnowflake()">
     71  No
     72</button>
     73</p>
     74<div id="snowflake-status"></div>
     75</div>
     76
     77<div id='cookies-disabled' style='display:none'>
     78<hr/>
     79<p>
     80Your browser has cookies disabled. You will need to enable them in order
     81to set Snowflake preferences.
     82</p>
     83</div>
     84
     85</div>
     86
     87<p>
    3388Minimum functionality has been achieved, and it is possible
    3489to bootstrap a Tor client to 100% using Snowflake, and the
    3590browsing experience using this PT is reasonable enough.
    gitweb.torproject.org/pluggable-transports/snowflake.git 
    74129<br/>
    75130Last update: <time>2018-12-20</time>
    76131
     132<script>
     133
     134// Defaults to opt-in.
     135var COOKIE_NAME = "snowflake-allow";
     136var COOKIE_LIFETIME = "Thu, 01 Jan 2038 00:00:00 GMT";
     137
     138function readCookie(cookie) {
     139  c = document.cookie.split('; ');
     140  cookies = {};
     141  for (i = 0 ; i < c.length ; i++) {
     142    pair = c[i].split('=');
     143    cookies[pair[0]] = pair[1];
     144  }
     145  return cookies[cookie];
     146}
     147
     148function enableSnowflake() {
     149  setSnowflakeCookie(1);
     150  location.reload();
     151}
     152
     153function disableSnowflake() {
     154  setSnowflakeCookie(0);
     155  location.reload();
     156}
     157
     158function setSnowflakeCookie(val) {
     159  document.cookie = COOKIE_NAME + "=" + val + ";path=/ ;expires=" + COOKIE_LIFETIME;
     160}
     161
     162window.onload = function() {
     163  if (navigator.cookieEnabled) {
     164    // Both JS and cookies enabled -- display normal buttons.
     165    document.getElementById('buttons').style = '';
     166  } else {
     167    // Display the cookies disabled message if necessary.
     168    document.getElementById('cookies-disabled').style = '';
     169  }
     170  var enabled = readCookie(COOKIE_NAME);
     171  var $status = document.getElementById('snowflake-status');
     172  if ("1" === enabled) {
     173    $status.innerHTML = 'Snowflake Proxy is ACTIVE <br/><br/>' +
     174    'Thank you for contributing to internet freedom!';
     175    $status.className = 'active';
     176  } else {
     177    $status.innerHTML = 'Snowflake Proxy is OFF';
     178    $status.className = '';
     179  }
     180}
     181</script>
     182
    77183</body>
    78184</html>
  • deleted file proxy/static/options.html

    diff --git a/proxy/static/options.html b/proxy/static/options.html
    deleted file mode 100644
    index bdffd51..0000000
    + -  
    1 <!doctype html>
    2 <html>
    3 <head>
    4   <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    5   <title>Snowflake - Options</title>
    6   <style>
    7   * {
    8     box-sizing: border-box;
    9     -webkit-transition: all 0.3s;
    10     -moz-transition: all 0.3s;
    11     transition: all 0.3s;
    12   }
    13   body {
    14     position: absolute;
    15     width: 100%; height: 100%; top: 0; margin: 0 auto;
    16     background-color: #424;
    17     color: #000;
    18     font-size: 1rem;
    19     text-align: center;
    20     font-family: monospace;
    21     background-image: url('koch.jpg');
    22   }
    23   .options {
    24     background-color: rgba(0,0,0,0.8);
    25     color: #fff;
    26     resize: none;
    27     position: relative; border: none;
    28     width: 30rem; min-width: 40em;
    29     padding: 3rem; margin: auto; margin-top: 1rem;
    30     cursor: default;
    31   }
    32   a { color: #88F; } a:hover { color: #fff; }
    33   #snowflake-status {
    34     color: #888;
    35   }
    36   .active {
    37     color: #2F2 !important;
    38   }
    39   </style>
    40 </head>
    41 <body>
    42   <div class="options">
    43   <h1>Snowflake Options</h1>
    44   <p>
    45   This page enables you to use your web browser as a proxy to help other
    46   Internet users in censored places.
    47   When you click yes, your browser will act as a
    48   censorship circumvention proxy
    49   as long as you are viewing a page with the snowflake badge.
    50   </p>
    51 
    52   <p>
    53   For more information on this system click
    54   <a href="https://snowflake.torproject.org/">here</a>.
    55   </p>
    56 
    57   <noscript>
    58   <hr/>
    59   Snowflake proxy requires javascript.
    60   <br/>
    61   To volunteer as a proxy, please enable javascript.
    62   </noscript>
    63 
    64   <div id='buttons' style='display:none'>
    65   <p>
    66   Do you want your browser to act as a proxy?
    67   </p>
    68 
    69   <p>
    70   <button onclick="enableSnowflake()">
    71     Yes
    72   </button>
    73   <button onclick="disableSnowflake()">
    74     No
    75   </button>
    76   </p>
    77   <div id="snowflake-status"></div>
    78   </div>
    79 
    80   <div id='cookies-disabled' style='display:none'>
    81   <hr/>
    82   <p>
    83   Your browser has cookies disabled. You will need to enable them in order
    84   to set Snowflake preferences.
    85   </p>
    86   </div>
    87 
    88 <script>
    89 
    90 // Defaults to opt-in.
    91 var COOKIE_NAME = "snowflake-allow";
    92 var COOKIE_LIFETIME = "Thu, 01 Jan 2038 00:00:00 GMT";
    93 
    94 function readCookie(cookie) {
    95   c = document.cookie.split('; ');
    96   cookies = {};
    97   for (i = 0 ; i < c.length ; i++) {
    98     pair = c[i].split('=');
    99     cookies[pair[0]] = pair[1];
    100   }
    101   return cookies[cookie];
    102 }
    103 
    104 function enableSnowflake() {
    105   setSnowflakeCookie(1);
    106   refreshStatus();
    107 }
    108 
    109 function disableSnowflake() {
    110   setSnowflakeCookie(0);
    111   refreshStatus();
    112 }
    113 
    114 function setSnowflakeCookie(val) {
    115   document.cookie = COOKIE_NAME + "=" + val + ";path=/ ;expires=" + COOKIE_LIFETIME;
    116 }
    117 
    118 function refreshStatus() {
    119   var enabled = readCookie(COOKIE_NAME);
    120   var $status = document.getElementById('snowflake-status');
    121   if ("1" === enabled) {
    122     $status.innerHTML = 'Snowflake Proxy is ACTIVE <br/><br/>' +
    123     'Thank you for contributing to internet freedom!';
    124     $status.className = 'active';
    125   } else {
    126     $status.innerHTML = 'Snowflake Proxy is OFF';
    127     $status.className = '';
    128   }
    129 }
    130 
    131 window.onload = function() {
    132   if (navigator.cookieEnabled) {
    133     // Both JS and cookies enabled -- display normal buttons.
    134     document.getElementById('buttons').style = '';
    135   } else {
    136     // Display the cookies disabled message if necessary.
    137     document.getElementById('cookies-disabled').style = '';
    138   }
    139   refreshStatus();
    140 }
    141 </script>
    142 </body>
    143 </html>