魔法书签tampermonkey

魔法书签,放到油猴。

tampermonkey 脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// ==UserScript==
// @name POP弹窗模板
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @require https://gitee.com/aqtech/appset/raw/master/mfsq/popjs.main.js
// @require https://gitee.com/aqtech/appset/raw/master/mfsq/popjs_net.js
// @author You
// @match http://*/*
// @match https://*/*
// @grant none
// ==/UserScript==
'use strict';
// Your code here...
var popdivid='popdivid';
mydoMF(popdivid);
afun(popdivid,'百度','pinbaidu();');
afun(popdivid,'正在加载....','getYiyan("yiyanid");','yiyanid','#F75000');
setTimeout(function () {getYiyan('yiyanid');}, 500);
// my dest

var msg=document.getElementById("yiyanid");
console.log(msg.innerText);
afun(popdivid,'测试弹窗','test("'+msg.innerText+'");');

function test(msgx){
//alert(msgx);

//console.log(clipboardData.getData("Text"));

}
document.addEventListener('copy', function(event){doPasteTxt();});
function doPasteTxt(){
navigator.clipboard.readText()
.then((text) => {

var src=window.location.href;
var newsrc2='https://www.m3u8play.com/?play=' + text;
//var newsrc='http://aqtech.gitee.io/appset/mfsq/vip.html?v=' + escape(encodeURI(newsrc2));
window.open(newsrc2);
})
.catch((err) => log('Async readText failed with error: "' + err + '"'));
}

主js popjs.main.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//验证成功后弹出内容菜单,弹出菜单
function PopIndex(popdivid,popdivtop,popdivright,acss,aoks,aerrs) {
function d(a) {
return a.indexOf('360ee') > -1 || a.indexOf('360se') > -1 || a.indexOf('se') > -1 || a.indexOf('aoyou') > -1 || a.indexOf('theworld') > -1 || a.indexOf('worldchrome') > -1 || a.indexOf('greenbrowser') > -1 || a.indexOf('qqbrowser') > -1 || a.indexOf('baidu') > -1
}
if(document.getElementById(popdivid)){
document.getElementById(popdivid).style.display='';
document.getElementById(popdivid).style.left='';
document.getElementById(popdivid).style.top=popdivtop;
document.getElementById(popdivid).style.right=popdivright;
}else{
var a = document.createElement('div');
a.id = popdivid,
a.style.cssText = acss,
a.innerHTML = aoks;
document.body.appendChild(a),
a.onclick = function() {
//a.style.display = 'none'
},
setTimeout(function() {
a.click()
},
8e4)
}
}

function dragFunc(id) {
var Drag = document.getElementById(id);
Drag.onmousedown = function(event) {
var ev = event || window.event;
event.stopPropagation();
var disX = ev.clientX - Drag.offsetLeft;
var disY = ev.clientY - Drag.offsetTop;
document.onmousemove = function(event) {
var ev = event || window.event;
Drag.style.left = ev.clientX - disX + "px";
Drag.style.top = ev.clientY - disY + "px";
Drag.style.cursor = "move";
};
};
Drag.onmouseup = function() {
document.onmousemove = null;
this.style.cursor = "default";
};
}
//执行空
function clickb(){
console.log('clickb');
}

//创建菜单,可选颜色和id
function afun(popdivid,atxt,afuntxt,aid,acolor){

var aidx='aaa'+atxt.replace(/\s+/g,"bb")+Math.random();
if(!aid){aid=aidx;}
if(!acolor){acolor="#1d7fe2";}

var ppa = '<a id=' + aid + ' style="color:'+acolor+';" href="javascript:void(0);" >' +atxt+ '</a>';
var ppp = document.createElement("p");
ppp.setAttribute("style","margin:0px;padding:0px;");//可行
ppp.setAttribute("class","alink");
ppp.innerHTML = ppa;
document.getElementById(popdivid).appendChild(ppp.cloneNode(true));

document.getElementById(aid).addEventListener("click", function(){eval(afuntxt);});
}

function mydoMF(popdivid){
var host_popjs='https://gitee.com/aqtech/appset/raw/master/mfsq/popjs2.js';
//p.popdivid,p.popdivtop,p.popdivright,p.acss,menuX(p),p.aerrs
var msg=true;
var user='user';
var pwd='pwd';
var src='src';
var ver='1.0';
var popdivid=popdivid;
var popdivtop="10px";
var popdivright="10px";
var popdivwidth="200px";
var acss='position: fixed; top: '+popdivtop+'; width:'+popdivwidth+';right: '+popdivright+'; padding: 10px; border: 1px solid rgb(92, 184, 229);border-radius: 5px; box-shadow: rgb(92, 184, 229) 0px 0px 20px; z-index: 999999;background-color: rgba(255, 255, 255, 0.8) !important;';
//结果输出
//var astyle='<style>';
var aoks='<style type="text/css"> \n ';
aoks=aoks+'.alink{text-align:left;display:block;line-height:30px;} \n ';
aoks=aoks+'.alink a{display:block;border-style:none;border-bottom-style:solid;border-bottom-width:1px;border-bottom-color:#ccc;} \n ';
aoks=aoks+'.alink a:link,.alink a:visited{color:#ff0000;font-size:14px;text-decoration:none;} \n ';
// aoks=aoks+'.alink a:link{color:#ff0000;height:14px;font-size:14px;text-decoration:none;} \n ';
aoks=aoks+'.alink a:hover{background-color: #def0f9} \n ';
// aoks=aoks+'.alink a:active{color:#ff0000;height:14px;font-size:14px;text-decoration:none;} \n ';
// aoks=aoks+'.alink a:visited{color:#ff0000;height:14px;font-size:14px;text-decoration:none;} \n ';
aoks=aoks+'</style> \n';
aoks=aoks+'<p class="alink" style="padding:0px;margin:0px;text-align:right;"><a href="https://wqian.net/blog/2018/0517-mfsq-index.html" target="_blank" style="display:inline;">帮助</a>&nbsp;&nbsp;<a id="hidedivx" href="javascript:void(0);" style="display:inline;">关闭</a></p>';

var aerrs='<p><a style="color:#1d7fe2" href="https://wqian.net/blog/2018/0517-mfsq-index.html" target="_blank">For More Help</a></p>';
var popjs='popjs2.js?t=222';

var p={
msg:msg,
user:user,
pwd:pwd,
src:src,
popdivid:popdivid,
popdivtop:popdivtop,
popdivright:popdivright,
acss:acss,
aoks:aoks,
aerrs:aerrs,
popjs:popjs
};
//弹出装载菜单
PopIndex(p.popdivid,p.popdivtop,p.popdivright,p.acss,menuX(p),p.aerrs);
//可移动
dragFunc(p.popdivid);
document.getElementById("hidedivx").addEventListener("click", function(){hidediv(popdivid);});
}


function doMF(host_popjs,p){
//弹出装载菜单
PopIndex(p.popdivid,p.popdivtop,p.popdivright,p.acss,menuX(p),p.aerrs);
//可移动
dragFunc(p.popdivid);
//运行其他函数
RunFun();

}
function RunFun(){
getYiyan('yiyanid');
}

function menuX(p){
var exfun= p.aoks;
//exfun=exfun+fmtEx('获取当前网址','pophref()');
//exfun=exfun+fmtEx('vip','vipview()');
//exfun=exfun+fmtEx('百度收录查询','pinbaidu()');
//exfun=exfun+fmtEx('360收录查询','pin360()');
//exfun=exfun+fmtEx('获取html','GetHtml(\''+p.src+'\')');
//exfun=exfun+fmtExID('yiyanid','加载一言...','getYiyan(\'yiyanid\')');
// exfun=exfun+fmtEx('查询网址通断','UrlOK(\''+p.src+'\')');

return exfun;
}

function fmtEx(txt,fun){
return '<p class="alink" style="margin:0px;padding:0px"><a style="color:#1d7fe2;" href="javascript:void(0);" onclick="' + fun + '">' +txt+ '</a></p>';
}
function fmtExID(id,txt,fun){
//添加带id的菜单
return '<p class="alink" style="margin:0px;padding:0px"><a id=' + id + ' style="color:#F75000;" href="javascript:void(0);" onclick="' + fun + '">' +txt+ '</a></p>';
}
//隐藏标签
function hidediv(id){
document.getElementById(id).style.display='none';
}

功能jspopjs_net.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function UrlOK(url){
// url="http://www.google.com";
$.ajax({
type: 'get',
cache: false,
url: url,
dataType: "jsonp", //跨域采用jsonp方式
processData: false,
timeout:5000, //超时时间,毫秒
complete: function (data) {
if (data.status==200) {
alert('ok');
} else {
alert("无效链接");
}
}
});

}
function GetHtml(url){
//$.getScript(url, function(html){
//alert(html);
//});
alert(document.getElementsByTagName("body")[0].innerHTML);
// document.getElementsByTagName("html")[0].innerHTML='oks';

}

//弹出窗口
function pophref(){
var src=window.location.href;
alert(src);
}
//vip解析
function vipview(){
var src=window.location.href;
var newsrc2='http://vip.wandhi.com/?v=' + src;
var newsrc='http://aqtech.gitee.io/appset/mfsq/vip.html?v=' + escape(encodeURI(newsrc2));
window.open(newsrc);
}
//百度收录查询
function pinbaidu(){
var newsrc='https://www.baidu.com/s?wd=site:'+ window.location.hostname;
//alert(newsrc);
window.open(newsrc);
}
//360收录查询
function pin360(){
var newsrc='https://www.so.com/s?q=site:'+ window.location.hostname;
//alert(newsrc);
window.open(newsrc);
}
function getYiyan(ElemtId){
fetch('https://v1.hitokoto.cn')
.then(function (res){
return res.json();
})
.then(function (data) {
var hitokoto = document.getElementById(ElemtId);
hitokoto.innerText = data.hitokoto;
})
.catch(function (err) {
console.error(err);
})
}