知乎截图设置

设置赞同以及字体大小

目前为 2020-07-03 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 知乎截图设置
  3. // @namespace zhjtsz
  4. // @version 0.11
  5. // @description 设置赞同以及字体大小
  6. // @author cyf0611
  7. // @match *://www.zhihu.com/question/*?1
  8. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.js
  9. // @run-at document-end
  10. // @grant unsafeWindow
  11. // @grant GM_setClipboard
  12. // ==/UserScript==
  13. (function() {
  14. 'use strict';
  15. function numFormat(num, type) {
  16. //type 1 逗号分隔符 2 转化万
  17. switch(type){
  18. case 1:
  19. return (num.toString().indexOf ('.') !== -1) ? num.toLocaleString() : num.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
  20. break;
  21. case 2:
  22. return num > 10000 ? (Number(num)/10000).toFixed(1) + "万" : num;
  23. break;
  24. }
  25. }
  26.  
  27. // add menu
  28. var formTree = '<style>.jtrow{margin:5px 0;}</style><form style="position:fixed;top:0;left:0;background-color:pink;z-index:100;padding:10px;font-size:16px!important;" id="settingForm"><b>默认开启编辑模式,可直接修改文字和图片</b><div class="jtrow">设置赞同数: <input type="number" id="agreeNum"></div> <div class="jtrow">设置评论数: <input type="number" id="discussNum"></div><div class="jtrow">字体放大比例: <input type="number" id="scaleNum" value=1.2></div><button type="button" id="settingBtn" class="Button SearchBar-askButton Button--primary Button--blue">修改</button></form>';
  29. $("#root").append(formTree);
  30. $("#settingBtn").on("click", function(){
  31. var agree_num = $("#agreeNum").val();
  32. var discuess_num = $("#discussNum").val();
  33. var scale_num = $("#scaleNum").val() - 0;
  34.  
  35. if(agree_num) {
  36. var votersDom = $(".Voters").eq(0);
  37. votersDom.text(numFormat(agree_num, 1) + " 人赞同了该回答");
  38. $(".Button.VoteButton.VoteButton--up").eq(0).text("赞同 " + numFormat(agree_num, 2));
  39. }
  40.  
  41.  
  42.  
  43. if(discuess_num) {
  44. $(".Button.ContentItem-action.Button--plain.Button--withIcon.Button--withLabel").eq(0).text(numFormat(discuess_num, 1) + " 条评论")
  45. }
  46.  
  47. if(scale_num) {
  48. $("body").css({"font-size":18*scale_num});
  49. }
  50.  
  51. })
  52. //开启编辑模式
  53. $(".Card.AnswerCard").each(function(){
  54. $(this).attr("contentEditable", "true");
  55. })
  56. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址