0%

QQ空间辅助点赞

QQ空间手滑点赞太麻烦,用键盘吧。

嗯,我文思枯竭了,编不出什么内容充实的文章,就写下过程贴代码吧

浏览器检查元素

通过完成的审查元素发现:

1
2
3
4
所有的列表,元素的id:     feed_friend_list
一个说说的,元素的class: f-single
点赞按钮,元素的class: qz_like_btn_v3
评论按钮,元素的class: qz_btn_reply

写脚本

之前考虑用jQuery实现,用油猴脚本,但是脚本对于加载jQuery有一点问题

因为QQ空间用了 $ 这个名字,但是不是jQuery,所以考虑用纯 js 实现。

后来啊。$ 不是可以用jQuery写么。就改成了jQuery实现

(jQuery真香)

用纯 js 添加点赞按钮的css

1
2
3
4
var style = document.createElement('style');
style.innerHTML="a.item-on {background-color: red;}"
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(style);

完整脚本 v0.1

(还没想好怎么解释这个脚本。直接贴代码)

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
// ==UserScript==
// @name QQ空间快速操作
// @namespace https://blog.tcpsoft.app/
// @version 0.1
// @description try to take over the world!
// @author tcpsoft
// @match https://user.qzone.qq.com/*
// @grant none
// ==/UserScript==
(function () {
// Your code here...
/* https://greasyfork.org/zh-CN/scripts/373979-qq%E7%A9%BA%E9%97%B4%E5%8A%A8%E6%80%81%E8%87%AA%E5%8A%A8%E7%82%B9%E8%B5%9E/code */
function up(){
console.log("上");
}
function left(){
console.log("左");
var first=jQuery(".f-single").eq(0);
first.find(".qz_btn_reply").click();
}
function down(){
console.log("下");
var first=jQuery(".f-single").eq(0);
console.log(first);
first.slideUp(function(){this.remove()});
//if(jQuery(".f-single").length==0){
// window.scrollTo(window.scrollX, document.documentElement.scrollHeight);
//}
}
function right(){
console.log("右 点赞");
var first=jQuery(".f-single").eq(0);
console.log(first);
var zan=first.find("a.qz_like_btn_v3[data-clicklog='like']");
console.log(zan.length);
if(zan.length!=0){
zan.eq(0).click();
}
first.slideUp(function(){this.remove()});
}
function beg(){
console.clear();
console.log("【【【【【】】】】】");
/*插入输入框*/
var $rect = jQuery('<div>\
<style>\
#rect {\
height: 100px; width: 160px; border:red 5px solid; position:fixed;\
z-index: 999; top:40px; margin-left:40%; margin-right:40%;\
}\
#rect:focus{ border:5px green solid; }\
</style>\
<textarea type="input" id="rect" value="">输入区操作:\n触摸板双指上下滑刷新动态\n下 下一条\n左 评论\n右 点赞</textarea></div>');
jQuery("body").append($rect);
/*红色点赞*/
jQuery("head").append("<style id=\"addedCSS\" type=\"text/css\">a.item-on {background-color: red;}</style>");
/*红色提示和文字
jQuery("div.user-vip-info").eq(0).html("<span style='color:red;font-size:50px'>OOKK.</span>");
*/
/*监听document的回车操作 37左 38上 39右 40下*/
jQuery("#rect").keydown(function(e){
//获取键盘输入的keyCode
//console.log(e)
var keycode = (Number)(e.keyCode);
console.log(keycode);
if(keycode == 37){//左
left();
}else if(keycode == 38){//上
up();
}else if(keycode == 39){//右
right();
}else if(keycode == 40){//下
down();
}
return false;
});
}
console.log("----等两秒----");
setTimeout(beg,2000);
})();

2020-08-01更新 v0.2

增加了修复网络的功能。妈妈再也不用担心更新不出来啦

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
// ==UserScript==
// @name QQ空间快速操作
// @namespace https://blog.tcpsoft.app/
// @version 0.2
// @description QQ空间用键盘操作,岂不美哉
// @author tcpsoft
// @match https://user.qzone.qq.com/*
// @grant none
// ==/UserScript==

(function () {
'use strict';
// Your code here...
/* https://greasyfork.org/zh-CN/scripts/373979-qq%E7%A9%BA%E9%97%B4%E5%8A%A8%E6%80%81%E8%87%AA%E5%8A%A8%E7%82%B9%E8%B5%9E/code */
function up(){
console.log("上");
}
function left(){
console.log("左");
var first=jQuery(".f-single").eq(0);
first.find(".qz_btn_reply").click();
}
function down(){
console.log("下");
var first=jQuery(".f-single").eq(0);
console.log(first);
first.slideUp(function(){this.remove()});
//if(jQuery(".f-single").length==0){
// window.scrollTo(window.scrollX, document.documentElement.scrollHeight);
//}
}
function right(){
console.log("右 点赞");
var first=jQuery(".f-single").eq(0);
console.log(first);
var zan=first.find("a.qz_like_btn_v3[data-clicklog='like']");
console.log(zan.length);
if(zan.length!=0){
zan.eq(0).click();
}
first.slideUp(function(){this.remove()});
}
function beg(){
console.clear();
console.log("【【【【【】】】】】");
/*插入输入框*/
var $rect = jQuery('<div id="rect_div">\
<style>\
#rect_div{\
position:fixed; z-index: 999; top:40px; margin-left:40%; margin-right:40%; width: 50%;\
}\
#rect {\
height: 100px; width: 200px; border:red 5px solid; \
}\
#rect:focus{ border:5px green solid; }\
#qzone_fix_button{\
float:left; height: 50px; width: 100px; border:skyblue 2px solid; \
}\
</style>\
<textarea type="input" id="rect" value="">输入区操作:\n触摸板双指上下滑刷新动态\n下 下一条\n左 评论\n右 点赞</textarea>\
<button id="qzone_fix_button" onclick="QZFL.cookie.set(\'page_engine_off\',1,\'qzone.qq.com\',\'/\',12);location = location.href;return false;">网络问题<br>立即修复</button></div>');
jQuery("body").append($rect);
/*红色点赞*/
jQuery("head").append("<style id=\"addedCSS\" type=\"text/css\">a.item-on {background-color: red;}</style>");
/*红色提示和文字
jQuery("div.user-vip-info").eq(0).html("<span style='color:red;font-size:50px'>OOKK.</span>");
*/
/*监听document的回车操作 37左 38上 39右 40下*/
jQuery("#rect").keydown(function(e){
//获取键盘输入的keyCode
//console.log(e)
var keycode = (Number)(e.keyCode);
console.log(keycode);
if(keycode == 37){//左
left();
}else if(keycode == 38){//上
up();
}else if(keycode == 39){//右
right();
}else if(keycode == 40){//下
down();
}
return false;
});
}
console.log("----等两秒----");
setTimeout(beg,2000);
})();

2020-08-16更新 v0.3

0.3版本,增加了简单的去除顶部的已点赞用户

代码:

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
155
156
157
158
159
160
161
162
163
164
165
// ==UserScript==
// @name QQ空间快速操作
// @namespace https://blog.tcpsoft.app/
// @version 0.3
// @description QQ空间用键盘操作,岂不美哉
// @author tcpsoft
// @match https://user.qzone.qq.com/*
// @grant none
// ==/UserScript==

(function () {
'use strict';
// Your code here...
/* https://greasyfork.org/zh-CN/scripts/373979-qq%E7%A9%BA%E9%97%B4%E5%8A%A8%E6%80%81%E8%87%AA%E5%8A%A8%E7%82%B9%E8%B5%9E/code */
var list=["Cortana","Cortana"];
function getFirstTime(){
var first=jQuery(".f-single").eq(0);
var timetime = first.find(".info-detail .ui-mr8.state").html();
console.log(timetime);
}
function faded(first){
getFirstTime();
first.slideUp(100,function(){this.remove()});
}
function clearLiked(){
jQuery("#finishedClearLiked").html("pending.");
var first=jQuery(".f-single").eq(0);
console.log(first);
if(first.length==0){
jQuery("#finishedClearLiked").html("finished.");
return;
}
var nickName = first.find(".f-nick a").html();
console.log(nickName);
var matchList = false;
for(i=0;i<list.length;i++){
if(nickName.indexOf(list[i])>-1){
matchList=true;
break;
}
}
if(matchList==true){
console.log("进入{pass}分支");
var second=jQuery(".f-single").eq(1);
var nextZan=second.find("a.qz_like_btn_v3[data-clicklog='cancellike']");//取消赞
console.log(nextZan.length);
if(nextZan.length!=0){ //下面有取消赞
console.log("下面有取消赞,所以pass");
first.remove();
setTimeout(clearLiked,100);
}
else{ //下面没有取消赞,停止
console.log("下面无取消赞,所以停止");
var nickName = second.find(".f-nick a").html();
console.log("下一个人是:",nickName);
jQuery("#finishedClearLiked").html("finished.");
}
}
else{
var zan=first.find("a.qz_like_btn_v3[data-clicklog='like']");
console.log(zan.length);
if(zan.length!=0){
jQuery("#finishedClearLiked").html("finished.");
}
else{
first.remove();
setTimeout(clearLiked,100);
}
}
}
function up(){
console.log("上");
jQuery("#finishedClearLiked").html("pending.");
clearLiked();
}
function left(){
console.log("左");
jQuery("#finishedClearLiked").html("free.");
var first=jQuery(".f-single").eq(0);
first.find(".qz_btn_reply").click();
}
function down(){
console.log("下");
jQuery("#finishedClearLiked").html("free.");
var first=jQuery(".f-single").eq(0);
console.log(first);
faded(first);
//if(jQuery(".f-single").length==0){
// window.scrollTo(window.scrollX, document.documentElement.scrollHeight);
//}
}
function right(){
console.log("右 点赞");
jQuery("#finishedClearLiked").html("free.");
var first=jQuery(".f-single").eq(0);
console.log(first);
var zan=first.find("a.qz_like_btn_v3[data-clicklog='like']");
console.log(zan.length);
if(zan.length!=0){
zan.eq(0).click();
}
faded(first);
}
function beg(){
console.clear();
console.log("【【【【【】】】】】");
/*插入输入框*/
var $rect = jQuery('<div id="rect_div">\
<style>\
#rect_div{\
position:fixed; z-index: 999; top:40px; margin-left:40%; margin-right:40%; width: 50%;\
}\
#rect {\
height: 120px; width: 200px; border:red 5px solid; \
}\
#rect:focus{ border:5px green solid; }\
#qzone_fix_button{\
float:left; height: 50px; width: 100px; border:skyblue 2px solid; \
}\
#clearLikedDiv{\
vertical-align: top;border: 2px solid yellow;width: 150px;height: 80px;\
display: inline-flex;flex-direction: column;background-color: wheat;\
}\
#finishedClearLiked{\
border: skyblue 2px inset; font-size: 1.5em;\
}\
#startClearLiked{\
width: 100%;flex-grow: 1;\
}\
</style>\
<textarea type="input" id="rect" value="">输入区操作:\n触摸板双指上下滑刷新动态\n上 清理顶部已点赞\n下 下一条\n左 评论\n右 点赞</textarea>\
<button id="qzone_fix_button" onclick="QZFL.cookie.set(\'page_engine_off\',1,\'qzone.qq.com\',\'/\',12);location = location.href;return false;">网络问题<br>立即修复</button>\
<div id="clearLikedDiv">\
<span id="finishedClearLiked">free.</span>\
<button id="startClearLiked">清理已点赞</button>\
</div>\
</div>');
jQuery("body").append($rect);
jQuery("#startClearLiked").click(clearLiked);
/*红色点赞*/
jQuery("head").append("<style id=\"addedCSS\" type=\"text/css\">a.item-on {background-color: red;}</style>");
/*红色提示和文字
jQuery("div.user-vip-info").eq(0).html("<span style='color:red;font-size:50px'>OOKK.</span>");
*/
/*监听document的回车操作 37左 38上 39右 40下*/
jQuery("#rect").keydown(function(e){
//获取键盘输入的keyCode
//console.log(e)
var keycode = (Number)(e.keyCode);
console.log(keycode);
if(keycode == 37){//左
left();
}else if(keycode == 38){//上
up();
}else if(keycode == 39){//右
right();
}else if(keycode == 40){//下
down();
}
return false;
});
}
console.log("----等两秒----");
setTimeout(beg,2000);
})();

2020-08-16更新 v0.4

增加显示最顶部五条动态内容,修复网络和状态条和删除顶部已点赞都放在最左边了

代码:

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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
// ==UserScript==
// @name QQ空间快速操作
// @namespace https://blog.tcpsoft.app
// @version 0.4
// @description QQ空间用键盘操作,岂不美哉
// @author tcpsoft
// @match https://user.qzone.qq.com/*
// @grant none
// ==/UserScript==

(function () {
'use strict';
// Your code here...
/* https://greasyfork.org/zh-CN/scripts/373979-qq%E7%A9%BA%E9%97%B4%E5%8A%A8%E6%80%81%E8%87%AA%E5%8A%A8%E7%82%B9%E8%B5%9E/code */
var list=["Cortana","今日百色","易锦教育","易锦大学","CUIT网络空间安全学院","丁凌娜","黄恋茹","Victor","墙"];
function getFirstTime(){
var first=jQuery(".f-single").eq(0);
var timetime = first.find(".info-detail .ui-mr8.state").html();
console.log(timetime);
}
function matchList(nickName){
var match = false;
for(i=0;i<list.length;i++){
if(nickName.indexOf(list[i])>-1){
match=true;
break;
}
}
return match;
}
function faded(first){
getFirstTime();
first.slideUp(100,function(){this.remove()});
}
function clearLiked(){
jQuery("#finishedClearLiked").html("pending.");
var first=jQuery(".f-single").eq(0);
console.log(first);
if(first.length==0){ //好友动态已经空了
jQuery("#finishedClearLiked").html("finished.");
return;
}
var nickName1 = first.find(".f-nick a").html();
console.log(nickName1);
var match1 = matchList(nickName1);
if(match1==true){ // 第一个人是列表
console.log("进入{pass}分支");
var second=jQuery(".f-single").eq(1);
var nextZan=second.find("a.qz_like_btn_v3[data-clicklog='cancellike']");//查找取消赞
console.log("第二个人有无取消赞:",nextZan.length);
if(nextZan.length!=0){ //下面有取消赞
console.log("下面有取消赞,所以pass");
first.remove();
setTimeout(clearLiked,125);
}
else{ //第二个人下面没有取消赞,
console.log("第二个人下面无取消赞,");
var nickName2 = second.find(".f-nick a").html();
console.log("第二个人:",nickName2);
var match2 = matchList(nickName2);
if(match2==true){ // 第二个人也是列表
console.log("进入{pass}分支");
var third=jQuery(".f-single").eq(2);
var nickName3 = second.find(".f-nick a").html();
console.log("第三个人:",nickName3);
var thirdZan=third.find("a.qz_like_btn_v3[data-clicklog='cancellike']");//取消赞
console.log("第三个人有无取消赞:",thirdZan.length);
if(thirdZan.length!=0){ //下面有取消赞
console.log("第三个人下面有取消赞,所以pass");
first.remove();
setTimeout(clearLiked,125);
}
else{ //下面没有取消赞,停止
console.log("下面无取消赞,所以停止");
jQuery("#finishedClearLiked").html("finished.");
}
}
}
}
else{
var zan=first.find("a.qz_like_btn_v3[data-clicklog='like']");
console.log("第一个人有无点赞按钮:",zan.length);
if(zan.length!=0){ // 有点赞按钮,结束
jQuery("#finishedClearLiked").html("finished.");
}
else{
first.remove();
setTimeout(clearLiked,125);
}
}
setTimeout(space,100);
}
function space(){
for(var iii=0;iii<5;iii++){
var one=jQuery(".f-single").eq(iii);
if(one.length==0){
jQuery("#statusTable").find("tr").eq(iii).find("td").eq(0).html("nickName");
jQuery("#statusTable").find("tr").eq(iii).find("td").eq(1).html("timestamp");
jQuery("#statusTable").find("tr").eq(iii).find("td").eq(2).html("content");
}
else{
var nickName = one.find(".f-nick a").html();
jQuery("#statusTable").find("tr").eq(iii).find("td").eq(0).html(nickName);
var time = one.find(".info-detail .ui-mr8.state").html();
jQuery("#statusTable").find("tr").eq(iii).find("td").eq(1).html(time);
var summary = one.find(".f-info").text();
jQuery("#statusTable").find("tr").eq(iii).find("td").eq(2).html(summary);
}
}
}
function up(){
console.log("上");
jQuery("#finishedClearLiked").html("pending.");
clearLiked();
setTimeout(space,100);
jQuery("#finishedClearLiked").html("finished.");
}
function left(){
console.log("左");
jQuery("#finishedClearLiked").html("free.");
var first=jQuery(".f-single").eq(0);
first.find(".qz_btn_reply").click();
setTimeout(space,100);
}
function down(){
console.log("下");
jQuery("#finishedClearLiked").html("free.");
var first=jQuery(".f-single").eq(0);
console.log(first);
faded(first);
setTimeout(space,100);
//if(jQuery(".f-single").length==0){
// window.scrollTo(window.scrollX, document.documentElement.scrollHeight);
//}
}
function right(){
console.log("右 点赞");
jQuery("#finishedClearLiked").html("free.");
var first=jQuery(".f-single").eq(0);
console.log(first);
var zan=first.find("a.qz_like_btn_v3[data-clicklog='like']");
console.log(zan.length);
if(zan.length!=0){
zan.eq(0).click();
}
faded(first);
setTimeout(space,150);
}
function beg(){
console.clear();
console.log("【【【【【】】】】】");
/*插入输入框*/
var $rect = jQuery('<div id="rect_div">\
<style>\
#rect_div{\
position: fixed; z-index: 999;top: 40px; width: 90%; text-align: center; left: 0px; right: 0px; margin-left: auto; margin-right: auto;\
}\
#rect {\
height: 140px; width: 210px; border:red 5px solid; \
}\
#rect:focus{ border:5px green solid; }\
#clearLikedDiv{\
vertical-align: top;border: 4px solid darkseagreen;width: 100px;height: 120px;\
display: inline-flex;flex-direction: column;background-color: wheat;\
}\
#qzone_fix_button{\
height: 50px; width: 100px; \
}\
#finishedClearLiked{\
border: skyblue 3px inset; font-size: 1.5em;\
}\
#startClearLiked{\
width: 100%;flex-grow: 1;\
}\
\
#statusTable{\
border-collapse: collapse;\
display: inline-table;\
vertical-align: top;\
}\
#statusTable tr td:nth-child(1){\
background-color: #FFFFCC;\
width: 100px;\
}\
#statusTable tr td:nth-child(2){\
background-color: #DDDDDD;\
width: 100px;\
}\
#statusTable tr td:nth-child(3){\
background-color: #CCFFCC;\
width: 300px;\
}\
</style>\
<div id="clearLikedDiv">\
<button id="qzone_fix_button" onclick="QZFL.cookie.set(\'page_engine_off\',1,\'qzone.qq.com\',\'/\',12);location = location.href;return false;">网络问题<br>立即修复</button>\
<span id="finishedClearLiked">free.</span>\
<button id="startClearLiked">清理已点赞</button>\
</div>\
<textarea type="input" id="rect" value="">输入区操作:\n触摸板双指上下滑刷新动态\n空格 加载前五条动态信息\n上 清理顶部已点赞\n下 下一条\n左 评论\n右 点赞</textarea>\
<table id="statusTable" border="2"><tr>\
<td>100</td><td>100</td><td>100</td>\
</tr><tr>\
<td>200</td><td>200</td><td>200</td>\
</tr><tr>\
<td>300</td><td>300</td><td>300</td>\
</tr><tr>\
<td>400</td><td>400</td><td>400</td>\
</tr><tr>\
<td>500</td><td>500</td><td>500</td>\
</tr></table>\
</div>');
jQuery("body").append($rect);
jQuery("#startClearLiked").click(clearLiked);
/*红色点赞*/
jQuery("head").append("<style id=\"addedCSS\" type=\"text/css\">a.item-on {background-color: red;}</style>");
/*红色提示和文字
jQuery("div.user-vip-info").eq(0).html("<span style='color:red;font-size:50px'>OOKK.</span>");
*/
/*监听document的回车操作 37左 38上 39右 40下*/
jQuery("#rect").keydown(function(e){
//获取键盘输入的keyCode
//console.log(e)
var keycode = (Number)(e.keyCode);
console.log(keycode);
if(keycode == 32){//空格
console.log("空格");
space();
}else if(keycode == 37){//左
left();
}else if(keycode == 38){//上
up();
}else if(keycode == 39){//右
right();
}else if(keycode == 40){//下
down();
}
return false;
});
}
console.log("----等两秒----");
setTimeout(beg,2000);
})();
坚持原创技术分享,您的支持将鼓励我继续创作!