NGA Display Like Value

NGA 赞踩按钮显示数值,默认悬停显示,可修改为一直显示。

  1. // ==UserScript==
  2. // @name NGA Display Like Value
  3. // @namespace https://gf.qytechs.cn/zh-CN/scripts/39475-nga-display-like-value
  4. // @version 0.1.0.20180312
  5. // @icon http://bbs.nga.cn/favicon.ico
  6. // @description NGA 赞踩按钮显示数值,默认悬停显示,可修改为一直显示。
  7. // @author Aglandy
  8. // @include /^https?:\/\/(bbs\.ngacn\.cc|nga\.178\.com|bbs\.nga\.cn)\/read.+/
  9. // @grant none
  10. // @require https://gf.qytechs.cn/scripts/39014-nga-user-script-loader/code/NGA%20User%20Script%20Loader.js
  11. // ==/UserScript==
  12.  
  13. //发布地址:http://bbs.ngacn.cc/read.php?tid=13647420
  14.  
  15. (function(){
  16.  
  17. function init(usl){
  18.  
  19. let $ = usl.$,
  20. dlv = commonui.displayLikeValue = {
  21. init: function(){
  22. let s;
  23. if(localStorage.displayLikeValue)
  24. s = parseInt(localStorage.displayLikeValue);
  25. else{
  26. s = 1;
  27. localStorage.displayLikeValue = s;
  28. }
  29. return s;
  30. },
  31. f: function(){
  32. let zc = $('a.white[title^="支持"]');
  33.  
  34. //还原默认
  35. zc.attr('title', '支持');
  36. zc.nextAll('a').attr('title', '反对');
  37. zc.next().show();
  38. zc.prev('span.white').remove();
  39. zc.nextAll('a').next('span.white').remove();
  40.  
  41. //显示数值
  42. if(dlv.s)
  43. zc.each(function(i, a){
  44. a = $(a);
  45. let pA = commonui.postArg.data[a.closest('span[id^=postc]').attr('id').replace(/[a-z]+/,'')];
  46. a.attr('title','支持('+ pA.score +')');
  47. a.nextAll('a').attr('title','反对('+ pA.score_2 +')');
  48. });
  49. else{
  50. zc.next().hide();
  51. zc.each(function(i, a){
  52. a = $(a);
  53. let pA = commonui.postArg.data[a.closest('span[id^=postc]').attr('id').replace(/[a-z]+/,'')];
  54. if(a.prev().attr('class') != 'white'){
  55. a.before('<span class="white" />');
  56. a.nextAll('a').after('<span class="white" />');
  57. }
  58. a.prev().html(pA.score + ' ');
  59. a.nextAll('a').next().html(' ' + -pA.score_2);
  60. });
  61. }
  62. }
  63. };
  64.  
  65. commonui.mainMenu.data[403] = {innerHTML: '显示赞踩数值设置',on: {event: 'click',func: function(e){
  66. let o = __SETTING.o = commonui.createadminwindow(),
  67. k = _$('/input').$0('type','checkbox','checked',0)._.on('click', function(){
  68. dlv.s = this.checked ? 1 : 0;
  69. localStorage.displayLikeValue = dlv.s;
  70. dlv.f();
  71. });
  72. o._.addContent(null);
  73. o._.addTitle('显示赞踩数值设置');
  74. o._.addContent(
  75. k,
  76. '悬停显示',
  77. _$('/br')
  78. );
  79. if(dlv.s)
  80. k._.attr('checked', 1);
  81. o._.show(e);
  82. }},parent: 18};
  83. commonui.mainMenu.data[18].subKeys.push(403);
  84.  
  85. dlv.s = usl.lS ? dlv.init() : 1;
  86.  
  87. dlv.f();
  88.  
  89. if(!usl.userScriptData.dlv)
  90. usl.userScriptData.dlv = dlv.f;
  91.  
  92. }
  93.  
  94. (function check(){
  95. try{
  96. if(commonui.userScriptLoader.$)
  97. init(commonui.userScriptLoader);
  98. else
  99. setTimeout(check, 5);
  100. }
  101. catch(e){
  102. setTimeout(check, 50);
  103. }
  104. })();
  105.  
  106. })();
  107.  
  108.  
  109.  
  110.  

QingJ © 2025

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