您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adding quick-navigation links
当前为
- // ==UserScript==
- // @name Quick nav
- // @version 2.1
- // @description Adding quick-navigation links
- // @author nicael
- // @include *://*.stackexchange.com/questions/*
- // @include *://*stackoverflow.com/questions/*
- // @include *://*serverfault.com/questions/*
- // @include *://*superuser.com/questions/*
- // @include *://*askubuntu.com/questions/*
- // @include *://*stackapps.com/questions/*
- // @include *://*mathoverflow.net/questions/*
- // @grant none
- // @namespace https://greasyfork.org/users/9713
- // ==/UserScript==
- $("body").append('<div style="text-align:right; position:fixed;top:20%;left:1px;"><div class="quick-nav" style="margin: 0 auto;width:80%;overflow:scroll;padding:5px;text-align:left;background-color:rgba(200,200,200,0.4)"><b>Quick navigation</b><hr><a href="#">Back to question</a><hr></div></div>');
- if($(document).width()<1350){$(".quick-nav").hide();}else{$(".quick-nav").show();}
- navControl();
- $(window).resize(function(){
- if($(document).width()<1350){$(".quick-nav").fadeOut();}else{$(".quick-nav").fadeIn();}
- navControl();
- })
- function navControl(){
- var width = ($(document).width()-$("#question-header").css("width").replace("px",""))/2-30;
- $(".quick-nav").parent().css({"width":width+"px"});
- }
- var answers = [];
- var votes = [];
- var owners = [];
- var reps = [];
- $(".answer").each(function(){
- answers.push($(this).data("answerid"));
- votes.push($(this).find(".vote-count-post").text());
- owners.push($(this).find(".post-signature:last a[href^='/users']").text());
- var rep = $(this).find(".post-signature:last .reputation-score").text();
- if($(this).find(".post-signature:last .community-wiki").length==0){
- if(rep!=""){
- reps.push(rep);
- } else {
- reps.push("del");
- }
- } else {
- reps.push("cw");
- }
- });
- for(var i=0;i<answers.length;i++){
- if(reps[i]=="cw"){
- $(".quick-nav").append('<a href="#'+answers[i]+'">'+(i+1)+'. ('+votes[i]+') Community Wiki Answer</a><br>');
- } else if(reps[i]=="del"){
- $(".quick-nav").append('<a href="#'+answers[i]+'">'+(i+1)+'. ('+votes[i]+') Answer by deleted user</a><br>');
- } else {
- $(".quick-nav").append('<a href="#'+answers[i]+'">'+(i+1)+'. ('+votes[i]+') Answer by '+owners[i]+' ('+reps[i]+')</a><br>');
- }
- }
- if(answers.length>18){
- $(".quick-nav").css({"height":"400px"})
- }