NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @author Dexmaster // @grant none // @include http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_form_submit // @name Test Script Saver (localStorage) // @namespace TestScript // @noframes // @run-at document-end // @version 0.2 // ==/UserScript== (function () { "use strict"; document.addEventListener("DOMContentLoaded", function () { var el = document.querySelector('html body form input[name="LastName"]'), my_vals = []; if (el !== undefined) { // If element exists if ((localStorage.my_vals === null) || (localStorage.my_vals === undefined) || (typeof localStorage.my_vals !== "string") || (localStorage.my_vals === "")) { my_vals[0] = el; // FIRST VAL IN ARRAY )) } else { my_vals = JSON.parse(localStorage.my_vals); if (my_vals.indexOf(el) < 0) { my_vals.push(el); // ADD VAL TO ARRAY } } if (typeof my_vals === "object") { localStorage.my_vals = JSON.stringify(my_vals); // SAVE VALS ARRAY TO STORAGE } } setTimeout(function(){ window.location.reload(); /* or window.location = window.location.href; */ }, (int)( 1000 * 60 * ( 30 + ( Math.random() * 30 ) ) ) ); // (1sec * 60 * (30 + 0~30)) 30~60 minutes console.log( localStorage.my_vals ); }); }());