NGA Display Like Value

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

当前为 2018-03-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NGA Display Like Value
  3. // @namespace none
  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. (function(){
  14.  
  15. function init(usl){
  16.  
  17. let $ = usl.$,
  18. dlv = commonui.displayLikeValue = {
  19. init: function(){
  20. let s;
  21. if(localStorage.displayLikeValue)
  22. s = parseInt(localStorage.displayLikeValue);
  23. else{
  24. s = 1;
  25. localStorage.displayLikeValue = s;
  26. }
  27. return s;
  28. },
  29. f: function(){
  30. let zc = $('a.white[title^="支持"]');
  31.  
  32. //还原默认
  33. zc.attr('title', '支持');
  34. zc.nextAll('a').attr('title', '反对');
  35. zc.next().show();
  36. zc.prev('span.white').remove();
  37. zc.nextAll('a').next('span.white').remove();
  38.  
  39. //显示数值
  40. if(dlv.s)
  41. zc.each(function(i, a){
  42. a = $(a);
  43. let pA = commonui.postArg.data[a.closest('span[id^=postc]').attr('id').replace(/[a-z]+/,'')];
  44. a.attr('title','支持('+ pA.score +')');
  45. a.nextAll('a').attr('title','反对('+ pA.score_2 +')');
  46. });
  47. else{
  48. zc.next().hide();
  49. zc.each(function(i, a){
  50. a = $(a);
  51. let pA = commonui.postArg.data[a.closest('span[id^=postc]').attr('id').replace(/[a-z]+/,'')];
  52. if(a.prev().attr('class') != 'white'){
  53. a.before('<span class="white" />');
  54. a.nextAll('a').after('<span class="white" />');
  55. }
  56. a.prev().html(pA.score + ' ');
  57. a.nextAll('a').next().html(' ' + -pA.score_2);
  58. });
  59. }
  60. }
  61. };
  62.  
  63. commonui.mainMenu.data[403] = {innerHTML: '显示赞踩数值设置',on: {event: 'click',func: function(e){
  64. let o = __SETTING.o = commonui.createadminwindow(),
  65. k = _$('/input').$0('type','checkbox','checked',0)._.on('click', function(){
  66. dlv.s = this.checked ? 1 : 0;
  67. localStorage.displayLikeValue = dlv.s;
  68. dlv.f();
  69. });
  70. o._.addContent(null);
  71. o._.addTitle('显示赞踩数值设置');
  72. o._.addContent(
  73. k,
  74. '悬停显示',
  75. _$('/br')
  76. );
  77. if(dlv.s)
  78. k._.attr('checked', 1);
  79. o._.show(e);
  80. }},parent: 18};
  81. commonui.mainMenu.data[18].subKeys.push(403);
  82.  
  83. dlv.s = usl.lS ? dlv.init() : 1;
  84.  
  85. dlv.f();
  86.  
  87. if(!usl.userScriptData.dlv)
  88. usl.userScriptData.dlv = dlv.f;
  89.  
  90. }
  91.  
  92. (function check(){
  93. try{
  94. if(commonui.userScriptLoader.$)
  95. init(commonui.userScriptLoader);
  96. else
  97. setTimeout(check, 5);
  98. }
  99. catch(e){
  100. setTimeout(check, 50);
  101. }
  102. })();
  103.  
  104. })();
  105.  
  106.  
  107.  
  108.  

QingJ © 2025

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