January 20, 2023

Запароленные странички для Taplink

Видеоинструкция:https://youtu.be/n-gztqAzUss

Пример:https://besttaplink.ru/p/9136ca/

Таблица для копирования: https://docs.google.com/spreadsheets/d/1khxTXhDlNML6mUepId0baMV3hgCtUu-SerfCYIDdtRU/edit#gid=0

Код:

<script>
  document.addEventListener('DOMContentLoaded', () => {
  var DOM = document.querySelector('body>*').outerHTML;
document.querySelector('body').innerHTML = " ";
  document.querySelector('body').insertAdjacentHTML('afterbegin', '<div class="form-wrapper" style="background-color: #2c3338;font-family: &quot;Open Sans&quot;, sans-serif;font-size: 0.875rem;font-weight: 400;line-height: 1.5;margin: 0;height: 100vh;position: fixed;width: 100vw;display: flex;align-items: center;"><div class="grid" style="inline-size: 90%;margin-inline: auto;max-inline-size: 20rem;"><div class="form login" style="display: grid;gap: 0.875rem;color: #eee;"><div class="form__field" style="display: flex;"><label for="login__password" style="border-radius: 0.25rem;padding: 1rem;background-color: #363b41;border-bottom-right-radius: 0;border-top-right-radius: 0;padding-inline: 1.25rem;"><svg class="icon" width="311" height="404" viewbox="0 0 311 404" fill="none" xmlns="http://www.w3.org/2000/svg" style="block-size: 1em;display: inline-block;fill: #606468;inline-size: 1em;vertical-align: middle;"><path fill-rule="evenodd" clip-rule="evenodd" d="M42 97.0073V185.507H22.5C8.1 185.507 1.5 200.507 0 208.007V364.007H311V208.007C311 185.207 284.667 183.507 271.5 185.507V97.0073C264 64.3406 230 -0.792698 154 0.0073022C78 0.807302 47.6667 65.0073 42 97.0073ZM200 185.507H110.5V107.007C113.167 93.8405 126.4 67.7072 158 68.5072C189.6 69.3072 199.167 94.5072 200 107.007V185.507ZM1 384.007H310.5C310.167 390.007 306 402.207 292 403.007C278 403.807 105.5 403.341 21 403.007C16.3333 402.507 5.8 398.007 1 384.007Z" fill="#C4C4C4"></path></svg><span class="hidden" style="border: 0;clip: rect(0 0 0 0);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;">Пароль</span></label><input id="login__password" type="password" name="password" class="form__input" placeholder="Пароль" required style="background-image: none;border: 0;color: inherit;font: inherit;margin: 0;outline: 0;padding: 1rem;transition: background-color 0.3s;flex: 1;inline-size: 100%;border-radius: 0.25rem;background-color: #3b4148;border-bottom-left-radius: 0;border-top-left-radius: 0;"></div><div class="form__field" style="display: flex;"><button type="submit" class="login-btn" style="display:block;background-image: none;border: 0;color: #eee;font: inherit;margin: 0;outline: 0;padding: .6em 2em;transition: background-color 0.3s;cursor: pointer;inline-size: 100%;border-radius: 0.25rem;background-color: #ea4c88;font-weight: 700;text-transform: uppercase;min-height:42px;">Принять</button></div></div></div></div>')
localStorage.removeItem('pass');
   var x = new XMLHttpRequest();
x.open("GET", "https://script.google.com/macros/s/AKfycbyC1g_D2HU8K_T6mvGJBlzhC_0Qn75OnzcZWBm1qajuGKTQvT5Fa8ayuRUKpYse2l9b/exec", true);
x.onload = function (){
  var text = x.responseText;
  var parsed = JSON.parse(x.responseText).result;
localStorage.setItem('pass', parsed);
}
x.send(null);
 
var input = document.querySelector('.login-btn');
input.onclick = function () {

 
  var code = document.getElementById("login__password").value;
var pass = localStorage.getItem('pass');
if (code == pass) {
var win = document.querySelector(".form-wrapper");
win.classList.add("close");
document.querySelector('body').insertAdjacentHTML('afterbegin', DOM)
}
  else {
    alert('неверный пароль!')
  }


}
var css = '.close{position: absolute;top: 0px;opacity: 0;pointer-events: none;transition: all 0.3s linear;}',
    head = document.head || document.getElementsByTagName('head')[0],
    style = document.createElement('style');

head.appendChild(style);

style.type = 'text/css';
if (style.styleSheet){
  // This is required for IE8 and below.
  style.styleSheet.cssText = css;
} else {
  style.appendChild(document.createTextNode(css));
}
 });
</script>