// ==UserScript==
// @name 知乎美化
// @namespace http://tampermonkey.net/
// @version 1.2.3
// @description ①【重要更新】增加夜间模式按钮 ②知乎题目栏增加举报、匿名、问题日志、快捷键四个按钮 ③知乎大多数按钮图标在鼠标悬停时变色,页面顶部的通知、私信按钮、回答下方的查看回复、喜欢按钮等 ④回答的发布时间移至顶部,图片原图显示,文字和卡片链接从知乎跳转改为直链 ⑤集成其他脚本的知乎视频下载功能
// @author AN drew
// @match *://www.zhihu.com/*
// @match https://zhuanlan.zhihu.com/*
// @match https://v.vzuu.com/video/*
// @match https://video.zhihu.com/video/*
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.1.1/jquery.min.js
// @require https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
// @connect zhihu.com
// @connect vzuu.com
// @grant GM_info
// @grant GM_download
// @grant unsafeWindow
// @downloadURL none
// ==/UserScript==
var publishtop=1;
var light='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDIC'+
'ItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTkxNjA2NzI5MzM4IiB'+
'jbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjkxNSIgd2lk'+
'dGg9IjMyIiBoZWlnaHQ9IjMyIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj5AZm9udC1mY'+
'WNlIHsgZm9udC1mYW1pbHk6IGVsZW1lbnQtaWNvbnM7IHNyYzogdXJsKCJjaHJv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'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
' C'+
'
'+
'
'+
'
'+
' :收藏'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
' X'+
'
'+
'
'+
'
'+
' :分享'+
'
'+
'
'+
'
'+
'
'+
'
'+
' 导航'+
'
'+
'
'+
'
'+
'
'+
' :下一项'+
'
'+
'
'+
'
'+
'
'+
'
'+
' :上一项'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
' G'+
'
'+
'
'+
'
'+
' :第一项'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
Shift'+
'
'+
' +'+
'
'+
'
'+
'
'+
' G'+
'
'+
'
'+
'
'+
' :最后一项'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
Shift'+
'
'+
' +'+
'
'+
'
'+
'
'+
' U'+
'
'+
'
'+
'
'+
' :向上滚动半屏'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
Shift'+
'
'+
' +'+
'
'+
'
'+
'
'+
' D'+
'
'+
'
'+
'
'+
' :向下滚动半屏'+
'
'+
'
'+
'
'+
'
'+
'
'+
' :搜索'+
'
'+
'
'+
'
'+
'
'+
'
'+
' :快捷键帮助'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
'+
'
')
function addReport0($QuestionHeaderActions,$more0)
{
$more0.hide()
var r0 =''
var $report0 = $(r0)
$report0.bind("click",function(){
$more0.find("button").click();
$(".Menu.QuestionHeader-menu").children().eq(2).click();
})
$more0.after($report0)
}
function addAnonymous($QuestionHeaderActions,$more)
{
var a =''
var $anonymous = $(a)
$anonymous.bind("click",function(){
$more.find("button").click();
$(".Menu.QuestionHeader-menu").children().eq(0).click();
})
$QuestionHeaderActions.append($anonymous)
}
function addLog($QuestionHeaderActions)
{
var url = window.location.href;
var end,href;
if(url.indexOf("answer")>-1)
{
end=url.indexOf("answer")
href = url.substring(0,end);
}
else
{
href=url+"/"
}
var L=''
var $log = $(L);
$QuestionHeaderActions.append($log)
}
function addShortCut($QuestionHeaderActions)
{
var s =''
var $shortcut = $(s)
$shortcut.css({"margin-left":"10px"})
$shortcut.click(function(){
$(".Modal-wrapper").show()
});
$QuestionHeaderActions.append($shortcut)
}
function addReport1($more1)
{
$more1.hide()
var r1 = ''
var $report1 = $(r1)
$report1.bind("click",function(){
$more1.find("button").click();
$(".Menu.AnswerItem-selfMenu").find("button").click();
})
$more1.after($report1)
}
function question()
{
if($(".Modal-wrapper").length==0)
{
$(document.body).append($hint)
$(".Modal-wrapper").hide()
$(".Modal-closeButton").click(function(){
$(".Modal-wrapper").hide()
})
}
var $QuestionHeaderActions = $("div.QuestionHeaderActions")
var $titlemore = $QuestionHeaderActions.find(".Zi--Dots").parent().parent().parent() //更多
var $titlereport = $QuestionHeaderActions.find(".Title.Zi--Report") //举报
var $anonymous = $(".Zi--Anonymous")//匿名
var $log = $(".Zi--Log") //日志
var $shortcut = $(".Zi--ShortCut") //快捷键
if($(".AppHeader-profileAvatar").length>0) //已登录
{
if($titlereport.length == 0) //未添加举报
{
addReport0($QuestionHeaderActions,$titlemore)
}
if($anonymous.length == 0) //未添加匿名
{
addAnonymous($QuestionHeaderActions,$titlemore)
}
if($log.length == 0) //未添加查看问题日志
{
addLog($QuestionHeaderActions)
}
if($shortcut.length == 0) //未添加快捷键帮助
{
addShortCut($QuestionHeaderActions)
}
var $ContentItem_actions = $(".ContentItem-actions")
$ContentItem_actions.each(function(){
var $Content_child5 = $(this).children().eq(5-1) //喜欢
var $Content_child6 = $(this).children().eq(6-1) //更多
var $Content_child7 = $(this).children().eq(7-1) //举报
if($ContentItem_actions.text().indexOf("设置") == -1)
{
if($Content_child7.length==0 || $Content_child7.text().indexOf("举报")==-1 ) //未添加举报
{
addReport1($Content_child6)
}
}
})
}
else //未登录
{
$(".Zi--Dots").parent().parent().parent().hide();
$log = $(".Zi--Log") //日志
$shortcut = $(".Zi--ShortCut") //快捷键
if($log.length == 0) //未添加查看问题日志
{
addLog($QuestionHeaderActions)
}
if($shortcut.length == 0) //未添加快捷键帮助
{
addShortCut($QuestionHeaderActions)
}
}
$(".QuestionHeaderActions .QuestionHeader-Comment").css({"margin": "0px 0px 0px 0px"})
$(".QuestionHeaderActions .Popover.ShareMenu").css({"margin": "0px 0px 0px 0px"})
$(".QuestionHeaderActions .Button.Button--plain.Button--withIcon.Button--withLabel").css({"margin": "0px 0px 0px 9px"})
$(".CommentCollapseButton").on("click",function(){
$(this).parent().parent().parent().prev().find(".Zi--Comment").attr("fill","currentColor")
})
$(".ContentItem.AnswerItem").each(function(){
if($(this).find(".ContentItem-time").length>0 && $(this).find(".ContentItem-time").find("span").text() != null)
{
if($(this).find(".ContentItem-time").text().indexOf("发布于")==-1)
{
var data_tooltip = $(this).find(".ContentItem-time").find("span").attr("data-tooltip");
var oldtext =$(this).find(".ContentItem-time").find("span").text();
$(this).find(".ContentItem-time").find("span").text(data_tooltip+"\xa0\xa0,\xa0\xa0"+oldtext);
}
if(publishtop==1)
{
if(!$(this).find(".ContentItem-time").parent().hasClass("ContentItem-meta"))
{
$(this).find(".ContentItem-time").appendTo($(this).find(".ContentItem-meta"))
}
}
}
})
var $QuestionButtonGroup = $(".QuestionHeader-footer-main").find(".QuestionButtonGroup")
$QuestionButtonGroup.children().eq(0).css({"margin": "0px 0px 0px 8px"})
$QuestionButtonGroup.children().eq(1).css({"margin": "0px 0px 0px 8px"})
$(".QuestionHeaderActions").children().eq(0).css({"margin": "0px 8px 0px 0px"})
$(".GoodQuestionAction-commonBtn").css("margin","0px 0px 0px 0px")
$(".Pc-card.Card").attr("style","display:none")
$(".Card.ViewAll").attr("style","background-color:#0084FF")
$(".QuestionMainAction.ViewAll-QuestionMainAction").attr("style","color:white;background-color:#0084FF")
}
function directLink()
{
var equal,colon,external_href,protocol,path,new_href;
$("a[class*='external']").each(function(){
if($(this).find("span").length>0)
{
new_href = $(this).text()
$(this).attr("href",decodeURIComponent(new_href))
}
else if($(this).attr("href").indexOf("link.zhihu.com/?target=") > -1)
{
external_href=$(this).attr("href")
equal = external_href.lastIndexOf("http")
colon = external_href.lastIndexOf("%3A")
protocol = external_href.substring(equal,colon)
path = external_href.substring(colon+5,external_href.length)
new_href = protocol+"://"+path
$(this).attr("href",decodeURIComponent(new_href))
}
})
$("a[class*='LinkCard']:not([class*='MCNLinkCard'])").each(function(){
if($(this).find("LinkCard-title").length>0 && $(this).find("LinkCard-title").indexOf("http")>-1 )
{
new_href = $(this).find("LinkCard-title").text()
$(this).attr("href",decodeURIComponent(new_href))
}
else if($(this).attr("href").indexOf("link.zhihu.com/?target=") > -1)
{
external_href=$(this).attr("href")
equal = external_href.lastIndexOf("http")
colon = external_href.lastIndexOf("%3A")
protocol = external_href.substring(equal,colon)
path = external_href.substring(colon+5,external_href.length)
new_href = protocol+"://"+path
$(this).attr("href",decodeURIComponent(new_href))
}
})
$(".TopstoryItem--advertCard").hide()
}
function addReport2($more2)
{
$more2.hide()
var r2 = ''
var $report2 = $(r2)
$report2.bind("click",function(){
$more2.find("button").click();
$(".Menu.Post-ActionMenu").find("button").click();
})
$more2.after($report2)
}
function zhuanlan()
{
$(".Recommendations-Main").hide()
var $ContentItem_actions = $(".ContentItem-actions")
var $child5 = $ContentItem_actions.children().eq(5-1)
var $child6 = $ContentItem_actions.children().eq(6-1)
if($child6.length == 0) //未添加举报
{
addReport2($child5)
}
if($(".ContentItem-time").text().indexOf("发布于")==-1)
{
var data_tooltip = $(".ContentItem-time").find("span").attr("data-tooltip");
var oldtext =$(".ContentItem-time").find("span").text();
$(".ContentItem-time").find("span").text(data_tooltip+"\xa0\xa0,\xa0\xa0"+oldtext);
}
if(publishtop==1 && $(".Post-Header").children().eq(3).length==0)
{
$(".ContentItem-time").css({"padding":"0px 0px 0px 0px","margin-top": "14px"})
$(".ContentItem-time").appendTo($(".Post-Header"))
}
}
function zvideo()
{
$(".ZVideo-sideColumn").hide()
}
function addReport3($more3)
{
$more3.hide()
var r3 ='';
var $report3 = $(r3)
$report3.bind("click",function(){
$more3.find("button").click();
$(".ClubHeaderInfoMoreButton-item").click();
})
$more3.after($report3)
}
function addReport4($more4)
{
$more4.hide()
var r4 = ''
var $report4 = $(r4)
$report4.bind("click",function(){
$more4.find("button").click();
$(".PostWebActionButtons-item").click();
})
$more4.after($report4)
}
function club()
{
var $ClubHeaderInfo_buttonGroup = $(".ClubHeaderInfo-buttonGroup")
var $child1 = $ClubHeaderInfo_buttonGroup.children().eq(1-1)
var $child2 = $ClubHeaderInfo_buttonGroup.children().eq(2-1)
if($child2.length > 0 && $child2.text().indexOf("签到") > -1 && $child2.text().indexOf("加入") == -1) //退出圈子
{
addReport3($child1)
}
$(".PostReaction").each(function(){
var post_child5 = $(this).children().eq(5-1)
var post_child6 = $(this).children().eq(6-1)
if(post_child6.length==0 || post_child6.text().indexOf("举报")==-1 ) //未添加举报
{
addReport4(post_child5)
}
})
}
function addReport5($more5)
{
$more5.hide()
var r5 = ''
var $report5 = $(r5)
$report5.bind("click",function(){
$more5.find("button").click();
$(".AnswerItem-selfMenu").children().eq(1).click();
})
$more5.after($report5)
}
function search()
{
$(".ContentItem-actions").each(function(){
var $child6 = $(this).children().eq(6-1)
var $child7 = $(this).children().eq(7-1)
if($child7.text().indexOf("收起") > -1)
{
addReport5($child6)
}
})
$(".ContentItem.AnswerItem").each(function(){
if($(this).find(".ContentItem-time").length>0 && $(this).find(".ContentItem-time").find("span").text() != null)
{
if($(this).find(".ContentItem-time").text().indexOf("发布于")==-1)
{
var data_tooltip = $(this).find(".ContentItem-time").find("span").attr("data-tooltip");
var oldtext =$(this).find(".ContentItem-time").find("span").text();
$(this).find(".ContentItem-time").find("span").text(data_tooltip+"\xa0\xa0,\xa0\xa0"+oldtext);
}
if(publishtop==1)
{
console.log($(this).find(".ContentItem-time").parent())
if(!$(this).find(".ContentItem-time").parent().hasClass("SearchItem-meta"))
{
$(this).find(".ContentItem-time").appendTo($(this).find(".SearchItem-meta"))
}
}
}
})
}
function lives()
{
$("[class*='LiveWechatSpread']").remove()
}
function collection()
{
$(".ContentItem-actions").each(function(){
var $child6 = $(this).children().eq(6-1)
var $child7 = $(this).children().eq(7-1)
if($child7.length==0 || $child7.text().indexOf("收起") > -1)
{
addReport5($child6)
}
})
}
function iconColor()
{
$(".Zi--List").parent().parent().hover(function(){
$(this).find(".Zi--List").attr("fill","#0084FF")
},function(){
$(this).find(".Zi--List").attr("fill","currentColor")
})
$(".Zi--Comment").parent().parent().hover(function(){
$(this).find(".Zi--Comment").attr("fill","#0084FF")
if($(this).closest(".QuestionHeaderActions").length>0)
$(this).attr("style","color:#0084FF;margin: 0px 0px 0px 9px;");
else
$(this).attr("style","color:#0084FF");
},function(){
if($(this).closest(".QuestionHeaderActions").length>0)
{
$(this).find(".Zi--Comment").attr("fill","currentColor")
$(this).attr("style","color:#8590A6;margin: 0px 0px 0px 9px;");
}
else
{
if($(this).prop('lastChild').nodeValue.indexOf("收起评论")==-1)
{
$(this).find(".Zi--Comment").attr("fill","currentColor")
$(this).attr("style","color:#8590A6");
}
}
})
$(".Zi--Comment").parent().parent().each(function(){
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue.indexOf("收起评论") > -1)
{
$(this).find(".Zi--Comment").attr("fill","#0084FF")
$(this).attr("style","color:#0084FF");
}
})
$(".Zi--Close").on("click",function(){
$(".Zi--Comment").parent().parent().each(function(){
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue.indexOf("收起评论") > -1)
{
$(this).find(".Zi--Comment").attr("fill","currentColor")
$(this).attr("style","color:#8590A6");
}
})
})
$(".Zi--Comments").parent().parent().hover(function(){
$(this).find(".Zi--Comments").attr("fill","#00FF7F")
$(this).attr("style","color:#00FF7F");
},function(){
if($(".Messages-content").length==0)
{
$(this).find(".Zi--Comments").attr("fill","currentColor")
$(this).attr("style","color:#8590A6");
}
})
$(".Zi--Reply").parent().parent().hover(function(){
$(this).find(".Zi--Reply").attr("fill","#32CD32")
$(this).attr("style","color:#32CD32");
},function(){
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue.indexOf("取消回复")==-1)
{
$(this).find(".Zi--Reply").attr("fill","currentColor")
$(this).attr("style","color:#8590A6");
}
})
$(".Zi--Reply").parent().parent().each(function(){
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue.indexOf("取消回复") > -1)
{
$(this).find(".Zi--Reply").attr("fill","#32CD32")
$(this).attr("style","color:#32CD32");
}
})
$(".Zi--Like").parent().parent().hover(function(){
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue.indexOf("踩") > -1 || $(this).attr("data-tooltip")=="不推荐")
{
$(this).find(".Zi--Like").attr("fill","black")
$(this).attr("style","color:black");
}
else
{
$(this).find(".Zi--Like").attr("fill","#FF4D82")
$(this).attr("style","color:#FF4D82;margin:0px;");
}
},function(){
if($(this).find("#topic-recommend").length>0 ||$(this).find("#topic-against").length>0 || $(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue.indexOf("取消踩") == -1)
$(this).find(".Zi--Like").attr("fill","currentColor")
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue.indexOf("踩") > -1 || $(this).attr("data-tooltip")=="不推荐")
$(this).attr("style","color:#8590A6;");
else
$(this).attr("style","color:#8590A6; margin:0px;");
})
$(".Zi--Like").parent().parent().each(function(){
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue=="取消踩")
$(this).find(".Zi--Like").attr("fill","black")
})
$(".Zi--Share").parent().parent().hover(function(){
$(this).find(".Zi--Share").attr("fill","blue")
if($(this).closest(".QuestionHeaderActions").length>0)
$(this).attr("style","color:blue;margin: 0px 0px 0px 9px;");
else
$(this).attr("style","color:blue;");
},function(){
$(this).find(".Zi--Share").attr("fill","currentColor")
if($(this).closest(".QuestionHeaderActions").length>0)
$(this).attr("style","color:#8590A6;margin: 0px 0px 0px 9px;");
else
$(this).attr("style","color:#8590A6;");
})
$(".Zi--Star").parent().parent().hover(function(){
$(this).find(".Zi--Star").attr("fill","orange")
$(this).attr("style","color:orange");
},function(){
$(this).find(".Zi--Star").attr("fill","currentColor")
$(this).attr("style","color:#8590A6");
})
$(".Zi--Heart").parent().parent().hover(function(){
$(this).find(".Zi--Heart").attr("fill","red")
$(this).attr("style","color:red");
},function(){
if($(this).prop('lastChild').nodeValue=="喜欢")
$(this).find(".Zi--Heart").attr("fill","currentColor")
$(this).attr("style","color:#8590A6");
})
$(".Zi--Heart").parent().parent().each(function(){
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue=="取消喜欢")
$(this).prop('lastChild').nodeValue="已喜欢"
if($(this).prop('lastChild').nodeValue!=null && $(this).prop('lastChild').nodeValue=="已喜欢")
{
$(this).find(".Zi--Heart").attr("fill","red")
$(this).attr("style","color:red");
}
})
$(".Zi--Report").parent().parent().hover(function(){
$(this).find(".Zi--Report").attr("fill","brown")
if($(this).closest(".QuestionHeaderActions").length>0)
$(this).attr("style","color:brown;margin: 0px 0px 0px 9px;");
else
$(this).attr("style","color:brown");
},function(){
$(this).find(".Zi--Report").attr("fill","currentColor")
if($(this).closest(".QuestionHeaderActions").length>0)
$(this).attr("style","color:#8590A6;margin: 0px 0px 0px 9px;");
else
$(this).attr("style","color:#8590A6");
})
$(".Zi--Bell").parent().parent().hover(function(){
$(this).find(".Zi--Bell").attr("fill","#FACB62")
},function(){
if($(".PushNotifications-content").length==0)
$(this).find(".Zi--Bell").attr("fill","currentColor")
})
$(".Zi--Bell").parent().parent().on("click",function(){
if($(".PushNotifications-content").length==0)
{
$(this).find(".Zi--Bell").attr("fill","#FACB62")
}
else
{
$(this).find(".Zi--Bell").attr("fill","currentColor")
}
})
$(".Zi--Heart.PushNotifications-tabIcon").parent().parent().hover(function(){
$(this).find(".Zi--Heart").attr("fill","#0084FF")
},function(){
$(this).find(".Zi--Heart").attr("fill","currentColor")
})
$(".Zi--Users").parent().parent().hover(function(){
$(this).find(".Zi--Users").attr("fill","#0084FF")
},function(){
$(this).find(".Zi--Users").attr("fill","currentColor")
})
$(".Zi--Anonymous").parent().parent().hover(function(){
$(this).find(".Zi--Anonymous").attr("fill","black")
$(this).attr("style","color:black;margin: 0px 0px 0px 9px;");
},function(){
$(this).find(".Zi--Anonymous").attr("fill","currentColor")
$(this).attr("style","color:#8590A6;margin: 0px 0px 0px 9px;");
})
$(".Zi--Log").parent().parent().hover(function(){
$(this).find(".Zi--Log").attr("fill","purple")
$(this).parent().attr("style","color:purple;margin: 0px 0px 0px 9px;");
},function(){
$(this).find(".Zi--Log").attr("fill","currentColor")
$(this).parent().attr("style","color:#8590A6;margin: 0px 0px 0px 9px;");
})
$(".Zi--ShortCut").parent().parent().hover(function(){
$(this).find(".Zi--ShortCut").attr("fill","#44B8A1")
$(this).attr("style","color:#44B8A1;margin: 0px 0px 0px 9px;");
},function(){
$(this).find(".Zi--ShortCut").attr("fill","currentColor")
$(this).attr("style","color:#8590A6;margin: 0px 0px 0px 9px;");
})
$(".Zi--Invite").parent().parent().hover(function(){
$(this).find(".Zi--ShortCut").attr("fill","black")
$(this).attr("style","color:black;margin: 0px 8px 0px 0px;");
},function(){
$(this).find(".Zi--ShortCut").attr("fill","currentColor")
$(this).attr("style","color:#8590A6;margin: 0px 8px 0px 0px;");
})
$(".Zi--Trash").parent().parent().hover(function(){
$(this).find(".Zi--Trash").attr("fill","#C70000")
},function(){
$(this).find(".Zi--Trash").attr("fill","currentColor")
})
$(".Zi--Emotion").parent().parent().hover(function(){
$(this).find(".Zi--Emotion").find("path").attr("fill","#0084FF")
},function(){
$(this).find(".Zi--Emotion").find("path").removeAttr("fill")
})
$(".Zi--AddImage").parent().parent().hover(function(){
$(this).find(".Zi--AddImage").find("path").attr("fill","#0084FF")
},function(){
$(this).find(".Zi--AddImage").find("path").removeAttr("fill")
})
$(".Zi--InsertImage").parent().hover(function(){
$(this).find(".Zi--InsertImage").find("path").attr("fill","#0084FF")
},function(){
$(this).find(".Zi--InsertImage").find("path").removeAttr("fill")
})
$(".Zi--InsertVideo").parent().hover(function(){
$(this).find(".Zi--InsertVideo").find("path").attr("fill","red")
},function(){
$(this).find(".Zi--InsertVideo").find("path").removeAttr("fill")
})
$(".Zi--InsertLink").parent().hover(function(){
$(this).find(".Zi--InsertLink").find("path").attr("fill","black")
},function(){
$(this).find(".Zi--InsertLink").find("path").removeAttr("fill")
})
$(".Zi--Folder").parent().hover(function(){
$(this).find(".Zi--Folder").find("path").attr("fill","#FF8C00")
},function(){
$(this).find(".Zi--Folder").find("path").removeAttr("fill")
})
$(".Zi--Settings").parent().parent().hover(function(){
$(this).find(".Zi--Settings").attr("fill","purple")
},function(){
$(this).find(".Zi--Settings").attr("fill","currentColor")
})
$(".CommentMoreReplyButton .Button").hover(function(){
$(this).attr("style","color:#00FF7F");
},function(){
$(this).attr("style","color:#8590A6");
})
$(".CommentCollapseButton").hover(function(){
$(this).find("Zi--ArrowUp").attr("fill","#0084FF")
$(this).attr("style","color:#0084FF; opacity:1; left:831.5px;");
},function(){
$(this).find("Zi--ArrowUp").attr("fill","currentColor")
$(this).attr("style","color:#8590A6; opacity:1; left:831.5px;");
})
$(".CommentCollapseButton").on("click",function(){
let $t =$(this).closest(".Comments-container").prev().find(".Zi--Comment").parent().parent();
$t.find(".Zi--Comment").attr("fill","currentColor")
$t.attr("style","color:#8590A6");
})
$(".CornerButton").hover(function(){
$(this).find(".Zi--BackToTop").attr("style","color:#0084FF");
},function(){
$(this).find(".Zi--BackToTop").attr("style","color:#8590A6");
})
$(".ContentItem-time").each(function(){
$(this).find("a").attr("style","border-bottom: 1px solid rgba(133,144,166,.72)")
})
$(".Button.ContentItem-action.ContentItem-rightButton.Button--plain").attr("style","color:#175199");
$(".QuestionRichText-more").attr("style","color:#0084FF");
$(".QuestionHeader-actions .Button").attr("style","color:#0084FF");
$(".Zi--Switch").attr("fill","#0084FF")
$(".Zi--Switch").parent().parent().css("color","#0084FF")
$(".Zi--Select").attr("fill","#0084FF")
$(".Zi--Select").parent().css("color","#0084FF")
if($.cookie('nightmode')==undefined)
$.cookie('nightmode', 0, { expires: 365, path: "/", domain: "zhihu.com" });
var $nightmode =$('')
$nightmode.hover(function(){
$(this).css("color","#0084FF");
},function(){
if( $("html").attr("data-theme")=="light")
{
$(this).css("color","black");
}
else
{
$(this).css("color","hsla(0,0%,100%,.8)");
}
})
$nightmode.click(function(){
if( $("html").attr("data-theme")=="light")
{
$("html").attr("data-theme","dark")
$(this).find("img").attr("src",light).attr("style","vertical-align:middle; width:20px; height:20px;")
$(this).find("span").text(" 日间模式")
$(this).find("span").attr("style","color:hsla(0,0%,100%,.8)")
$.cookie('nightmode', 1, { expires: 365, path: "/", domain: "zhihu.com" });
}
else
{
$("html").attr("data-theme","light")
$(this).find("img").attr("src",dark).attr("style","vertical-align:middle; width:18px; height:18px;")
$(this).find("span").text(" 夜间模式")
$(this).find("span").attr("style","color:black")
$.cookie('nightmode', 0, { expires: 365, path: "/", domain: "zhihu.com" });
}
})
if($("#nightmode").length==0)
{
$(".SearchBar").after($nightmode)
$(".ColumnPageHeader-WriteButton").before($nightmode.css("margin-right","50px"))
}
if($.cookie('nightmode')==1)
{
$("html").attr("data-theme","dark")
$("#nightmode").find("img").attr("src",light).attr("style","vertical-align:middle; width:20px; height:20px;")
$("#nightmode").find("span").text(" 日间模式")
$("#nightmode").find("span").attr("style","color:hsla(0,0%,100%,.8)")
}
else
{
$("html").attr("data-theme","light")
$("#nightmode").find("img").attr("src",dark).attr("style","vertical-align:middle; width:18px; height:18px;")
$("#nightmode").find("span").text(" 夜间模式")
$("#nightmode").find("span").attr("style","color:black")
}
$(".Tabs-link.AppHeader-TabsLink").hover(function(){
$(this).attr("style","color:#0084FF");
},function(){
if( $("html").attr("data-theme")=="light")
{
$(this).attr("style","color:#8590A6");
}
else
{
$(this).attr("style","color:#606A80");
}
})
}
function index()
{
$(".Card.TopstoryItem").each(function(){
if($(this).find(".ContentItem-time").length>0 && $(this).find(".ContentItem-time").find("span").text() != null)
{
if($(this).find(".ContentItem-time").text().indexOf("发布于")==-1)
{
var data_tooltip = $(this).find(".ContentItem-time").find("span").attr("data-tooltip");
var oldtext =$(this).find(".ContentItem-time").find("span").text();
$(this).find(".ContentItem-time").find("span").text(data_tooltip+"\xa0\xa0,\xa0\xa0"+oldtext);
}
if(publishtop==1)
{
$(this).find(".ContentItem-time").appendTo($(this).find(".ContentItem-meta"))
}
}
})
$(".Card.GlobalSideBar-category>a").hide();
}
function people()
{
$(".ContentItem").each(function(){
if($(this).find(".ContentItem-time").length>0 && $(this).find(".ContentItem-time").find("span").text() != null)
{
if($(this).find(".ContentItem-time").text().indexOf("发布于")==-1)
{
var data_tooltip = $(this).find(".ContentItem-time").find("span").attr("data-tooltip");
var oldtext =$(this).find(".ContentItem-time").find("span").text();
$(this).find(".ContentItem-time").find("span").text(data_tooltip+"\xa0\xa0,\xa0\xa0"+oldtext);
}
if(publishtop==1)
{
if(!$(this).find(".ContentItem-time").parent().hasClass("ContentItem-meta"))
{
$(this).find(".ContentItem-time").appendTo($(this).find(".ContentItem-meta"))
}
}
}
})
}
function originalPic()
{
$("img").each(function(){
if($(this).attr("data-original")!=undefined && !$(this).hasClass("comment_sticker"))
{
if($(this).attr("src") != $(this).attr("data-original"))
$(this).attr("src",$(this).attr("data-original"))
}
})
$(".Modal-inner").css({"overflow-y":"hidden"})
}
//知乎视频下载功能来自脚本https://greasyfork.org/zh-CN/scripts/39206-%E4%B8%8B%E8%BD%BD%E7%9F%A5%E4%B9%8E%E8%A7%86%E9%A2%91
function downloadVideo()
{
(async () => {
if (window.location.host == 'www.zhihu.com') return;
const playlistBaseUrl = 'https://lens.zhihu.com/api/videos/';
//const videoBaseUrl = 'https://video.zhihu.com/video/';
const videoId = window.location.pathname.split('/').pop(); // 视频id
const menuStyle = 'transform:none !important; left:auto !important; right:-0.5em !important;';
const playerId = 'player';
const coverSelector = '#' + playerId + ' > div:first-child > div:first-child > div:nth-of-type(2)';
const controlBarSelector = '#' + playerId + ' > div:first-child > div:first-child > div:last-child > div:last-child > div:first-child';
const svgDownload = '';
let player = document.getElementById(playerId);
let resolutionMap = {'标清': 'sd', '高清': 'ld', '超清': 'hd'};
let videos = []; // 存储各分辨率的视频信息
let downloading = false;
function getBrowerInfo() {
let browser = (function (window) {
let document = window.document;
let navigator = window.navigator;
let agent = navigator.userAgent.toLowerCase();
// IE8+支持.返回浏览器渲染当前文档所用的模式
// IE6,IE7:undefined.IE8:8(兼容模式返回7).IE9:9(兼容模式返回7||8)
// IE10:10(兼容模式7||8||9)
let IEMode = document.documentMode;
let chrome = window.chrome || false;
let system = {
// user-agent
agent: agent,
// 是否为IE
isIE: /trident/.test(agent),
// Gecko内核
isGecko: agent.indexOf('gecko') > 0 && agent.indexOf('like gecko') < 0,
// webkit内核
isWebkit: agent.indexOf('webkit') > 0,
// 是否为标准模式
isStrict: document.compatMode === 'CSS1Compat',
// 是否支持subtitle
supportSubTitle: function () {
return 'track' in document.createElement('track');
},
// 是否支持scoped
supportScope: function () {
return 'scoped' in document.createElement('style');
},
// 获取IE的版本号
ieVersion: function () {
let rMsie = /(msie\s|trident.*rv:)([\w.]+)/;
let match = rMsie.exec(agent);
try {
return match[2];
} catch (e) {
return IEMode;
}
},
// Opera版本号
operaVersion: function () {
try {
if (window.opera) {
return agent.match(/opera.([\d.]+)/)[1];
}
else if (agent.indexOf('opr') > 0) {
return agent.match(/opr\/([\d.]+)/)[1];
}
} catch (e) {
return 0;
}
}
};
try {
// 浏览器类型(IE、Opera、Chrome、Safari、Firefox)
system.type = system.isIE ? 'IE' :
window.opera || (agent.indexOf('opr') > 0) ? 'Opera' :
(agent.indexOf('chrome') > 0) ? 'Chrome' :
//safari也提供了专门的判定方式
window.openDatabase ? 'Safari' :
(agent.indexOf('firefox') > 0) ? 'Firefox' :
'unknow';
// 版本号
system.version = (system.type === 'IE') ? system.ieVersion() :
(system.type === 'Firefox') ? agent.match(/firefox\/([\d.]+)/)[1] :
(system.type === 'Chrome') ? agent.match(/chrome\/([\d.]+)/)[1] :
(system.type === 'Opera') ? system.operaVersion() :
(system.type === 'Safari') ? agent.match(/version\/([\d.]+)/)[1] :
'0';
// 浏览器外壳
system.shell = function () {
if (agent.indexOf('edge') > 0) {
system.version = agent.match(/edge\/([\d.]+)/)[1] || system.version;
return 'Edge';
}
// 遨游浏览器
if (agent.indexOf('maxthon') > 0) {
system.version = agent.match(/maxthon\/([\d.]+)/)[1] || system.version;
return 'Maxthon';
}
// QQ浏览器
if (agent.indexOf('qqbrowser') > 0) {
system.version = agent.match(/qqbrowser\/([\d.]+)/)[1] || system.version;
return 'QQBrowser';
}
// 搜狗浏览器
if (agent.indexOf('se 2.x') > 0) {
return '搜狗浏览器';
}
// Chrome:也可以使用window.chrome && window.chrome.webstore判断
if (chrome && system.type !== 'Opera') {
let external = window.external;
let clientInfo = window.clientInformation;
// 客户端语言:zh-cn,zh.360下面会返回undefined
let clientLanguage = clientInfo.languages;
// 猎豹浏览器:或者agent.indexOf("lbbrowser")>0
if (external && 'LiebaoGetVersion' in external) {
return 'LBBrowser';
}
// 百度浏览器
if (agent.indexOf('bidubrowser') > 0) {
system.version = agent.match(/bidubrowser\/([\d.]+)/)[1] ||
agent.match(/chrome\/([\d.]+)/)[1];
return 'BaiDuBrowser';
}
// 360极速浏览器和360安全浏览器
if (system.supportSubTitle() && typeof clientLanguage === 'undefined') {
let storeKeyLen = Object.keys(chrome.webstore).length;
let v8Locale = 'v8Locale' in window;
return storeKeyLen > 1 ? '360极速浏览器' : '360安全浏览器';
}
return 'Chrome';
}
return system.type;
};
// 浏览器名称(如果是壳浏览器,则返回壳名称)
system.name = system.shell();
// 对版本号进行过滤过处理
// System.version = System.versionFilter(System.version);
} catch (e) {
// console.log(e.message);
}
return system;
})(window);
if (browser.name == undefined || browser.name == '') {
browser.name = 'Unknown';
browser.version = 'Unknown';
}
else if (browser.version == undefined) {
browser.version = 'Unknown';
}
return browser;
}
function fetchRetry(url, options = {}, times = 1, delay = 1000, checkStatus = true) {
return new Promise((resolve, reject) => {
// fetch 成功处理函数
function success(res) {
if (checkStatus && !res.ok) {
failure(res);
}
else {
resolve(res);
}
}
// 单次失败处理函数
function failure(error) {
times--;
if (times) {
setTimeout(fetchUrl, delay);
}
else {
reject(error);
}
}
// 总体失败处理函数
function finalHandler(error) {
throw error;
}
function fetchUrl() {
return fetch(url, options)
.then(success)
.catch(failure)
.catch(finalHandler);
}
fetchUrl();
});
}
// 下载指定url的资源
async function downloadUrl(url, name = (new Date()).valueOf() + '.mp4') {
let browser = getBrowerInfo();
// Greasemonkey 需要把 url 转为 blobUrl
if (GM_info.scriptHandler == 'Greasemonkey') {
let res = await fetchRetry(url);
let blob = await res.blob();
url = URL.createObjectURL(blob);
}
// Chrome 可以使用 Tampermonkey 的 GM_download 函数绕过 CSP(Content Security Policy) 的限制
if (window.GM_download) {
GM_download({url, name});
}
else {
// firefox 需要禁用 CSP, about:config -> security.csp.enable => false
let a = document.createElement('a');
a.href = url;
a.download = name;
// a.target = '_blank';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(function () {
URL.revokeObjectURL(url);
}, 100);
}
}
function humanSize(size) {
let n = Math.log(size) / Math.log(1024) | 0;
return (size / Math.pow(1024, n)).toFixed(0) + ' ' + (n ? 'KMGTPEZY'[--n] + 'B' : 'Bytes');
}
if (!player) return;
// 获取视频信息
const res = await fetchRetry(playlistBaseUrl + videoId, {
headers: {
'referer': 'refererBaseUrl + videoId',
'authorization': 'oauth c3cef7c66a1843f8b3a9e6a1e3160e20' // in zplayer.min.js of zhihu
}
}, 3);
const videoInfo = await res.json();
// 获取不同分辨率视频的信息
for (let [key, video] of Object.entries(videoInfo.playlist)) {
video.name = key;
if (!videos.find(v => v.width == video.width)) {
videos.push(video);
}
}
// 按分辨率大小排序
videos = videos.sort(function (v1, v2) {
return v1.width == v2.width ? 0 : (v1.width > v2.width ? 1 : -1);
}).reverse();
document.addEventListener('DOMNodeInserted', (evt) => {
let domControlBar = evt.relatedNode.querySelector(':scope > div:last-child > div:first-child');
if (!domControlBar || domControlBar.querySelector('.download')) return;
let domFullScreenBtn = domControlBar.querySelector(':scope > div:nth-last-of-type(1)');
let domResolutionBtn = domControlBar.querySelector(':scope > div:nth-last-of-type(3)');
let domDownloadBtn, defaultResolution, buttons;
if (!domFullScreenBtn || !domFullScreenBtn.querySelector('button')) return;
// 克隆分辨率菜单或全屏按钮为下载按钮
domDownloadBtn = (domResolutionBtn && (domResolutionBtn.className == domFullScreenBtn.className))
? domResolutionBtn.cloneNode(true)
: domFullScreenBtn.cloneNode(true);
defaultResolution = domDownloadBtn.querySelector('button').innerText;
// 生成下载按钮图标
domDownloadBtn.querySelector('button:first-child').outerHTML = domFullScreenBtn.cloneNode(true).querySelector('button').outerHTML;
domDownloadBtn.querySelector('svg').innerHTML = svgDownload;
domDownloadBtn.className = domDownloadBtn.className + ' download';
buttons = domDownloadBtn.querySelectorAll('button');
// button 元素添加对应的下载地址
buttons.forEach(dom => {
let video = videos.find(v => v.name == resolutionMap[dom.innerText || defaultResolution]);
video = video || videos[0];
dom.dataset.video = video.play_url;
if (dom.innerText) {
(dom.innerText = `${dom.innerText} (${humanSize(video.size)})`);
}
else if (buttons.length == 1) {
dom.nextSibling.querySelector('div').innerText = humanSize(video.size);
}
});
// 鼠标事件 - 显示菜单
domDownloadBtn.addEventListener('pointerenter', () => {
let domMenu = domDownloadBtn.querySelector('div:nth-of-type(1)');
if (domMenu) {
domMenu.style.cssText = menuStyle + 'opacity:1 !important; visibility:visible !important';
}
});
// 鼠标事件 - 隐藏菜单
domDownloadBtn.addEventListener('pointerleave', () => {
let domMenu = domDownloadBtn.querySelector('div:nth-of-type(1)');
if (domMenu) {
domMenu.style.cssText = menuStyle;
}
});
// 鼠标事件 - 选择菜单项
domDownloadBtn.addEventListener('pointerup', event => {
if (downloading) {
alert('当前正在执行下载任务,请等待任务完成。');
return;
}
let e = event.srcElement || event.target;
while (e.tagName != 'BUTTON') {
e = e.parentNode;
}
downloadUrl(e.dataset.video);
});
// 显示下载按钮
domControlBar.appendChild(domDownloadBtn);
});
})();
}
(function() {
'use strict';
if($.cookie('nightmode')!=undefined)
{
if($.cookie('nightmode')==1)
{
$("html").attr("data-theme","dark")
$("#nightmode").find("img").attr("src",light).attr("style","vertical-align:middle; width:20px; height:20px;")
$("#nightmode").find("span").text(" 日间模式")
$("#nightmode").find("span").attr("style","color:hsla(0,0%,100%,.8)")
}
else
{
$("html").attr("data-theme","light")
$("#nightmode").find("img").attr("src",dark).attr("style","vertical-align:middle; width:18px; height:18px;")
$("#nightmode").find("span").text(" 夜间模式")
$("#nightmode").find("span").attr("style","color:black")
}
}
var css = 'html[data-theme=dark] .css-1qefhqu{background-color:#1A1A1A}'+
'.TopstorySideNav-link{color:black}'+
'html[data-theme=dark] .TopstorySideNav-link{color:#606A80}'+
'html[data-theme=dark] .TopstorySideNav-link:hover{background-color:#F0F2F7}'+
'html[data-theme=dark] .TopstorySideNav-link.is-active{color:#0084FF}'
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.type = 'text/css';
if(style.styleSheet)
{
style.styleSheet.cssText = css;
}
else
{
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
setInterval(directLink,100)
setInterval(iconColor,100)
setInterval(originalPic,100)
setInterval(downloadVideo,100)
if(window.location.href.indexOf("question") > -1)
setInterval(question, 300);
else if(window.location.href.indexOf("zvideo") > -1)
setInterval(zvideo, 300);
else if(window.location.href.indexOf("club") > -1)
setInterval(club, 300);
else if(window.location.href.indexOf("search") > -1)
setInterval(search, 300);
else if(window.location.href.indexOf("lives") > -1)
setInterval(lives, 300);
else if(window.location.href.indexOf("collection") > -1)
setInterval(collection, 300);
else if(window.location.href.indexOf("zhuanlan") > -1)
setInterval(zhuanlan, 300);
else if(window.location.href.indexOf("people") > -1)
setInterval(people, 300);
else
setInterval(index, 300);
// Your code here...
})();