一个自用的脚本,所生成的密码仅建议作为实际密码的组成部分使用
目前為
// ==UserScript==
// @name 密码生成器
// @namespace wdssmq
// @description 一个自用的脚本,所生成的密码仅建议作为实际密码的组成部分使用
// @include http://*
// @include https://*
// @version 1.3
// @grant none
// ==/UserScript==
(function () {
'use strict';
var host = window.location.host;
var hash = window.location.hash.replace(/#/g, "");
var strHash = fnGetHash(host, 65537);
console.log(strHash);
if (parseInt(GetCookie(host)) < 3 || $n("input[type='password']")) {
var domH2 = fnAdd(strHash);
SetCookie(host, parseInt(GetCookie(host)) + 1, 180);
}
function fnGetHash(host, i) {
host = host.replace(/.*?([^\.]+\.[^\.]+)$/g, "$1");
i = parseInt(i);
var intHost = parseInt(host, 36);
var daysStamp = parseInt((new Date()).getTime() / (1000 * 60 * 60 * 24));
var result = "";
result = parseInt((daysStamp + (intHost % 181)) / 181);
result = result + i + intHost;
result = result * 181;
return host + " - " + result.toString(36);
}
function $n(e) {
return document.querySelector(e);
}
function $na(e) {
return document.querySelectorAll(e);
}
function fnAdd(text) {
var h2 = document.createElement('h2');
var textnode = document.createTextNode(text);
h2.appendChild(textnode);
h2.setAttribute('style', "background-color: rgb(252, 248, 227);border: 1px solid rgb(250, 235, 204);border-radius: 4px;padding: 5px;z-index: 1060;margin: 0px auto;position: fixed;bottom: 0px;width: 100%;font-size: 15px;line-height: 1.2em;text-align: center;color: #000;");
$n("body").insertBefore(h2, $n("body").childNodes[0]);
h2.onclick = function () {
h2.style.display = "none";
};
return h2;
}
function SetCookie(sName, sValue, iExpireDays) {
var path = (typeof(cookiespath) == "undefined") ? "/" : cookiespath;
if (iExpireDays) {
var dExpire = new Date();
dExpire.setTime(dExpire.getTime() + parseInt(iExpireDays * 24 * 60 * 60 * 1000));
document.cookie = sName + "=" + escape(sValue) + "; expires=" + dExpire.toGMTString() + "; path=" + path;
} else {
document.cookie = sName + "=" + escape(sValue) + "; path=" + path;
}
}
function GetCookie(sName) {
var arr = document.cookie.match(new RegExp("(^| )" + sName + "=([^;]*)(;|$)"));
if (arr !== null) {
return unescape(arr[2]);
}
return 0;
}
})();