// ==UserScript== // @name 知乎 显示匿名按钮、查看问题日志按钮、快捷键帮助按钮 // @namespace http://tampermonkey.net/ // @version 0.6.1 // @description 显示匿名按钮、查看问题日志按钮、快捷键帮助按钮 // @author AN drew // @match https://www.zhihu.com/question/* // @require https://code.jquery.com/jquery-3.1.1.min.js // @grant none // @downloadURL none // ==/UserScript== function addAnonymous($QuestionHeaderActions,$child5) { var a =''; var $anonymous = $(a) $anonymous.bind("click",function(){ $child5.find("button").click(); $(".Menu.QuestionHeader-menu > button").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); var $Popover = $('
') $Popover.append($log) $QuestionHeaderActions.append($Popover) } function addShortCut($QuestionHeaderActions) { var s =''; var $shortcut = $(s) $shortcut.click(function(){ $(".Modal-wrapper").show() }); $QuestionHeaderActions.append($shortcut) } function addBtn() { var $hint =$('
'+ '
'+ '
'+ ' '+ '
'+ '
'+ '
') if($(".Modal-wrapper").length==0) { $(document.body).append($hint) $(".Modal-wrapper").hide() $(".Modal-closeButton").click(function(){ $(".Modal-wrapper").hide() }) } var $QuestionHeaderActions = $("div.QuestionHeaderActions") var $child4 = $QuestionHeaderActions.children().eq(4-1) var $child5 = $QuestionHeaderActions.children().eq(5-1) var $child6 = $QuestionHeaderActions.children().eq(6-1) var $child7 = $QuestionHeaderActions.children().eq(7-1) var $child8 = $QuestionHeaderActions.children().eq(8-1) if($child4.length>0 && $child4.text().indexOf("举报")> -1) //已登录 { $child5.attr("style","display:none") if($child6.length == 0) //未添加匿名 { addAnonymous($QuestionHeaderActions,$child5) } if($child7.length == 0) //未添加查看问题日志 { addLog($QuestionHeaderActions) } if($child8.length == 0) //未添加查看键盘快捷键 { addShortCut($QuestionHeaderActions) } } else //未登录 { $child4.attr("style","display:none") if($child5.length == 0) //未添加查看问题日志 { addLog($QuestionHeaderActions) } if($child6.length == 0) //未添加查看键盘快捷键 { addShortCut($QuestionHeaderActions) } } $(".Pc-card.Card").attr("style","display:none") } (function() { 'use strict'; $(".Card.ViewAll").attr("style","background-color:#0084FF") $(".QuestionMainAction.ViewAll-QuestionMainAction").attr("style","color:white") setInterval(addBtn, 300); // Your code here... })();