-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYuKeTang_Print2PDF.js
64 lines (59 loc) · 2.33 KB
/
YuKeTang_Print2PDF.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
// ==UserScript==
// @name 雨课堂课件导出为pdf
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description 雨课堂课件ppt导出为pdf,需要后端支持,详见https://github.com/ShevonKuan/yuektang_ppt2pdf
// @author shevon
// @match https://changjiang.yuketang.cn/web/print
// @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function () {
'use strict';
setTimeout(function () { console.log('开始执行'); }, 3000);
$('.controls-btns').append('<p class="print fuckyuketang" title="打印">脚本打印</p>');
$('.fuckyuketang').on('click', function () {
var link = new Array();
$('.fuckyuketang').html('开始获取图片资源信息...');
var link = new Array();
$.each($('img.pptimg'), function () {
link.push($(this).attr('src'));
});
$('.fuckyuketang').html('检查打印服务器连接...');
GM_xmlhttpRequest({
method: "GET",
url: "http://localhost:63321/",
headers: {
"Content-Type": "application/json;charset=utf-8"
},
data: JSON.stringify({
'status': 'ok'
}),
onload: function () {
alert('开始打印...');
GM_xmlhttpRequest({
method: "POST",
url: "http://localhost:63321/print",
headers: {
"Content-Type": "application/json;charset=utf-8"
},
data: JSON.stringify({
'title': $(document).attr('title'),
'link': link
}),
onload: function () {
alert('已完成打印');
},
onerror: function () {
alert("请求失败");
}
});
$('.fuckyuketang').html('脚本打印');
},
onerror: function () {
alert("找不到服务器请重试");
$('.fuckyuketang').html('脚本打印');
}
});
})
})();