-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshaka.js
94 lines (89 loc) · 2.8 KB
/
shaka.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
function initBind() {
console.log("init success");
//增加特定按钮
var href = window.location.href;
//只能从详细页获取视频地址,所以首页和列表页面没有用处
setTimeout(function() {
if(href.indexOf("page-index.html") >0){
//首页
//homeVideo();
}else if(href.indexOf("page-topic-details.html") >0){
//话题列表页面
//topicVideo();
}else if(href.indexOf("page-feed.html") >0){
//详细页面
detailVideo();
}
}, 1000);
}
//定时加按钮
function homeVideo(){
$(".j-feed-item:not(.exists)").each(function(){
var vinfo=$("<div class='get_video_info'>GET LINK</div>");
var href=$(this).find("a").eq(0).attr("href");
vinfo.data("link",href);
$(this).append(vinfo);
showText2(vinfo);
$(this).addClass("exists");
});
}
function topicVideo(){
$(".figure-item:not(.exists)").each(function(){
var vinfo=$("<div class='get_video_info'>GET LINK</div>");
var href=$(this).find("a").eq(0).attr("href");
vinfo.data("link",href);
$(this).append(vinfo);
showText2(vinfo);
$(this).addClass("exists");
});
}
function detailVideo(){
if($("#my-video").length>0){
showText("--------------------");
showText($("#my-video").attr("src"));
var bcimg = $(".vjs-poster").css("background-image");
//url("http://xp.qpic.cn/oscar_pic/0/1047_316316b5a65c483d99f5a04fc04cpict/0")
bcimg=bcimg.substr(5);
bcimg=bcimg.substring(0,bcimg.indexOf("\""));
var title = $(".j-materialName").html();
showText(bcimg);
showText(title);
}else{
showText("not found");
}
}
function showText2(ele){
$(ele).mouseover(function(){
//console.log($(this).data());
var data=$(this).data();
$("#video_result").prepend($("<div>").html(escapeHTML("http://shaka.qq.com"+data["link"])));
$("#video_result").prepend("<div>------------------------------</div>");
/*$.each(data, function(ind,ele1) {
$("#video_result").prepend($("<div>").html(escapeHTML(ele1)));
});*/
return false;
});
}
function showText(ele) {
$("#video_result").prepend($("<div>").html(escapeHTML(ele)));
}
$(function() {
//增加样式表
var style = "<style type=\"text/css\">\
#video_result{position:fixed;right:10px;bottom:10px;height:200px;width:700px;z-index:999;background:#fff;padding:10px;overflow-y: scroll;color:#000;}\
.get_video_info{position: absolute;top: 5px;left: 5px;z-index: 550;background: #fff;padding:5px 10px;border-radius: 5px;border:1px solid #ddd;color:#000;}\
.mod-figure-list .figure-item{position: relative;}\
</style>";
$("head").append(style);
$("body").append("<div id='video_result'></div>")
initBind();
});
function escapeHTML(str) {
return str.replace(/[&"'<>]/g, (m) => ({
"&": "&",
'"': """,
"'": "'",
"<": "<",
">": ">"
})[m]);
}