jandan comment refresh

try to take over the world!

当前为 2018-02-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name jandan comment refresh
  3. // @namespace mtdwss@gmail.com
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match http*://jandan.net/pic*
  8. // @match http*://jandan.net/ooxx*
  9. // @match http*://jandan.net/duan*
  10. // @match http*://jandan.net/top
  11. // @match http*://jandan.net/drawings*
  12. // @match http*://jandan.net/pond*
  13. // @match http*://jandan.net/zhoubian*
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. 'use strict';
  19.  
  20. if (window.top != window.self) return;
  21. window.refreshComment = function (node) {
  22. node = node.parent().parent('div');
  23. var c = node.attr('id').split('-')[2];
  24. node.children('.tucao-hot, .tucao-list, .jandan-tucao-more, .jandan-tucao-close, .tucao-form, #tucao-gg').remove().empty();
  25. var a = $('<div class="tucao-tmp">数据加载中....biubiubiu....</div>');
  26. node.append(a);
  27. $.ajax({
  28. url: "/tucao/" + c,
  29. method: "GET",
  30. dataType: "json",
  31. success: function (f) {
  32. node.children('.tucao-tmp').remove().empty();
  33. if (f.code != 0) {
  34. alert(f.msg);
  35. return;
  36. }
  37. if (f.hot_tucao.length) {
  38. tucao_show_hot(node, f.hot_tucao);
  39. }
  40. tucao_show_list(node, f.tucao);
  41. if (f.has_next_page) {
  42. tucao_show_more_btn(node, c);
  43. }
  44. tucao_show_close_btn(node, c);
  45. tucao_show_form(node, c);
  46. },
  47. error: function (e) {
  48. a.html("hmm....something wrong...");
  49. }
  50. });
  51. };
  52. $(document).bind('DOMNodeInserted', function (e) {
  53. var element = e.target;
  54. element = $(element);
  55. if (element.hasClass('tucao-form')) {
  56. var node = element.parent('div');
  57. if(node.find('.tucao-refresh').length) return;
  58. node.prepend('<div class="tucao-refresh" style="text-align: right;"><span style="cursor: pointer;" onclick="refreshComment($(this))">刷新</span></div>');
  59. }
  60. });
  61. })();