// ==UserScript==
// @name 给大佬点赞!👍
// @namespace http://tampermonkey.net/
// @version 0.2.0
// @description 自动或手动给大佬们回复随机短句+👍!多次点击手动回复按钮即可切换短句!
// @author 张仨
// @match https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=*
// @grant GM_registerMenuCommand
// @grant unsafewindows
// @downloadURL https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=1148&extra=page%3D1
// @supportURL https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=1148&extra=page%3D1
// @homepageURL https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=1148&extra=page%3D1
// ==/UserScript==
//因为按钮是悬浮在窗口固定位置,如果不想在论坛主页看到按钮就需要精准匹配@match
(function() { //声明一个函数,也是定义一个函数的关键字
'use strict'; //严格模式:字面量表达式,严格模式下你不能使用未声明的变量,保证代码运行的安全,同样的代码,在"严格模式"中可能会报错(¬、¬)
var button,beasetag; //一个是新元素,一个是body元素
button = document.createElement("div"); //创建新元素
beasetag = document.querySelector("body"); //搜寻body元素
beasetag.appendChild(button); //将新元素作为子节点插入到body元素的最后一个子节点之后
button.innerHTML = "
"; //创建按钮并赋予id,以这组形式可以添加多个按钮
button.style = "position:fixed;bottom:700px;right:750px;width:200px;height:200px;opacity:1;color:white;text-align:center;line-height:60px;cursor:pointer;";
/*css样式为
position:fixed;生成固定定位的元素,相对于浏览器窗口进行定位。元素的位置通过 "left", "top", "right" 以及 "bottom" 属性进行规定。
bottom:15px;距窗口底部15px
right:15px;距窗口右边15px
width:60px;内容的宽度60px
height:60px;内容的高度60px
background:black;内边距的颜色和内容的颜色设置为黑色,不包括外边距和边框(不好看已删)
opacity:0.75;不透明度设置为0.75,1为完全不透明
color:white;指定文本的颜色为白色
text-align:center;指定元素文本的水平对齐方式为居中对齐
line-height:60px;设置行高,通过设置为等于该元素的内容高度的值,配合text-align:center;可以使div的文字居中
cursor:pointer;定义了鼠标指针放在一个元素边界范围内时所用的光标形状为一只手*/
//创建数组
var items =['ggnb!!!👍',
'ggnb!!!👍*99999',
'(ง •_•)งgg加油👍',
'd=====( ̄▽ ̄*)b👍',
'脚本不错,感谢大佬👍',
'千言万语,表达不了我的感激之情 ggnb!!!👍',
];
document.getElementById('id001').onclick = function(){ //找到按钮1的id,点击该按钮后执行以下代码
var randomItem = items[Math.floor(Math.random() * items.length)]; //随机公式
document.getElementById('fastpostmessage').value =randomItem; //将获取到的随机数组输入到框内
document.querySelector('#fastpostrefresh').checked=true //选中(点击)一个框
document.querySelector('#fastpostsubmit').click() //自动点击提交回复
}
document.getElementById('id002').onclick = function(){ //找到按钮2的id,点击该按钮后执行以下代码
document.querySelector('#fastpostmessage').focus();//滚动到输入框位置
button.style = "position:fixed;bottom:1px;right:850px;width:200px;height:200px;opacity:1;color:white;text-align:center;line-height:60px;cursor:pointer;"; //改变按钮位置
var randomItem = items[Math.floor(Math.random() * items.length)];
document.getElementById('fastpostmessage').value =randomItem;
}
let id=GM_registerMenuCommand ("申请支持的论坛或想要添加的短句", function(){ //右键菜单
window.location.href="https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=1148&extra=page%3D1";
}, "h");
})();