一个自用的脚本,所生成的密码仅建议作为实际密码的组成部分使用
目前為
// ==UserScript==
// @name 密码生成器+复制当前页面
// @namespace wdssmq
// @description 一个自用的脚本,所生成的密码仅建议作为实际密码的组成部分使用
// @include http://*
// @include https://*
// @version 1.5
// @require https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js
// @grant GM_addStyle
// ==/UserScript==
(function () {
'use strict';
if (window.frames.length != parent.frames.length) {
// alert('在iframe中');
return false;
}
// 复制按钮;
var $btn = document.createElement("button");
var nodeText = document.createTextNode("复制");
$btn.appendChild(nodeText);
$btn.setAttribute("class", "clip-btn");
//$btn.setAttribute("data-title", document.title + '\n' + document.location.href);
//var $p = document.getElementsByTagName("div")[0];
//$p.parentNode.insertBefore($btn, $p);
var domBody = document.getElementsByTagName("body")[0];
domBody.appendChild($btn);
new Clipboard('.clip-btn', {
text: function (trigger) {
if (!document.title)
document.title = "【√】RSS获取各种资源更新";
trigger.innerHTML = "已复制";
trigger.style.display = "none";
//return trigger.getAttribute('data-title');
return document.title + '\n' + document.location.href;
}
});
/* jshint multistr:true */
GM_addStyle('\
.clip-btn{\
position: fixed;\
right: 5px;\
top: 7px;\
cursor: pointer;\
margin: 0px;\
font-size: 12px;\
line-height: 1;\
font-weight: bold;\
padding: 4px 6px;\
border: 1px solid #999;\
border-radius: 2px;\
background-color: #f6f6f6;\
box-shadow: 0px 1px 0px #FFF inset, 0px -1px 2px #BBB inset;\
color: #333;\
z-index: 9999;\
}');
// 密码Hash
var host = window.location.host;
var hash = window.location.hash.replace(/#/g, "");
var strHash = fnGetHash(host, 65537);
console.log(strHash);
if (parseInt(GetCookie(host)) < 115 || $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]);
new Clipboard(h2, {
text: function (trigger) {
trigger.innerHTML = "已复制";
trigger.style.display = "none";
//return trigger.getAttribute('data-title');
return text;
}
});
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;
}
})();