🏠 Home 

NGA Display Like Value

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


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