Skip to content

Instantly share code, notes, and snippets.

@DarkMatterMatt
Last active December 31, 2017 21:00
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 DarkMatterMatt/d9092fea491c7de5bebf7b1c4cee10af to your computer and use it in GitHub Desktop.
Save DarkMatterMatt/d9092fea491c7de5bebf7b1c4cee10af to your computer and use it in GitHub Desktop.
AutoLogin_for_VexForums.tamper.js
// ==UserScript==
// @name AutoLogin for VexForums
// @namespace MattMoran
// @version 1.0.0
// @description VexForums logs itself out frequently. It's a PITA.
// @updateURL https://gist.githubusercontent.com/DarkMatterMatt/d9092fea491c7de5bebf7b1c4cee10af/raw/
// @author Matt Moran
// @copyright Matt Moran 2017
// @match https://www.vexforum.com/*
// ==/UserScript==
(function() {
"use strict";
// if not logged in, log in
if ($(".item-login")[0]) {
var url = window.location.href;
// if not on login page, click on login link
if (!url.startsWith("https://www.vexforum.com/index.php/user/login?return=")) {
//var currentPage = url.substring(url.indexOf("/index.php/") + 11); // + 11 to exclude /index.php/
//window.location = "https://www.vexforum.com/index.php/user/login?return=" + encodeURI(currentPage);
$(".item-login a")[0].click();
}
else {
if (localStorage.getItem("autologin_username")) {
if (!$("input[name='username']").val()) {
$("input[name='username']").val(localStorage.getItem("autologin_username"));
}
if (!$("input[name='password']").val()) {
$("input[name='password']").val(window.atob(localStorage.getItem("autologin_password")));
}
$("input[name='remember']").prop("checked", true);
$("form").submit();
}
else {
var elem = $(".sheetContent");
var css = `
scroll: auto;
z-index: 1;
color: black;
background-color: white;
padding: 1em;
position: absolute;
top: ${elem.offset().top}px;
left: ${elem.offset().left}px;
height: ${elem.outerHeight()}px;
width: ${elem.outerWidth()}px;`;
var intro_html = `
<div id="autologin" style="${css}">
<h3>AutoLogin for VexForums</h3>
<p>
When you login your username and password will be saved in <a href="https://www.w3schools.com/html/html5_webstorage.asp">HTML5 Local Storage</a> <i>in a plain-text format</i>.
</p>
<p>
<strong>Do not use this script on public computers.</strong>
</p>
<p>
If you do not accept this then uninstall the <i>AutoLogin for VexForums</i> Tampermonkey script before logging in.
<button id="autologin_btn">I have read and understand the information above</button><br>
</p>
<span style="position: relative; bottom: 0; font-size: 0.7em; color: #999">&copy; Matt Moran 2017</span>
</div>
`;
$("body").append(intro_html);
$("#autologin_btn").one("click", () => {
$("#autologin").remove();
$("form").on("submit", () => {
localStorage.setItem("autologin_username", $("input[name='username']").val());
localStorage.setItem("autologin_password", window.btoa($("input[name='password']").val()));
});
});
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment