Reddit link expander

Changes continue this thread links so that they load inline

当前为 2015-05-18 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Reddit link expander
  3. // @description Changes continue this thread links so that they load inline
  4. // @author James Skinner <spiralx@gmail.com> (http://github.com/spiralx)
  5. // @namespace http://spiralx.org/
  6. // @match *://*.reddit.com/r/*/comments/*
  7. // @version 0.2.0
  8. // @grant GM_getResourceURL
  9. // @run-at document-start
  10. // @resource spinner http://cdn2.inlinkz.com/load.gif
  11. // @resource expand http://www.iba-berlin.com/design/iba_berlin/javascript/partner_ajax/images/icon_expand.gif
  12. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js
  13. // @require https://gf.qytechs.cn/scripts/7602-mutation-observer/code/mutation-observer.js
  14. // ==/UserScript==
  15.  
  16. var spinnerUrl = GM_getResourceURL('spinner'),
  17. expandUrl = GM_getResourceURL('expand');
  18.  
  19.  
  20. var observer = new MutationSummary({
  21. callback: function(summaries) {
  22. //console.info('Added %d spans', summaries[0].added.length);
  23. summaries[0].added.forEach(function(elem) {
  24. var $span = jQuery(elem),
  25. $a = $span.children('a'),
  26. href = $a.prop('href');
  27. //console.log(href);
  28.  
  29. jQuery('<img src="' + expandUrl + '">')
  30. .css({
  31. display: 'inline-block',
  32. height: '11px',
  33. width: '11px',
  34. 'min-height': '11px',
  35. 'min-width': '11px',
  36. position: 'relative',
  37. top: '1px',
  38. marginRight: '4px',
  39. visibility: 'visible'
  40. })
  41. .prependTo($a);
  42.  
  43. $a
  44. .css('font-size', '1.1em')
  45. .one('click', function() {
  46. $span
  47. .removeClass('deepthread')
  48. .html('<img src="' + spinnerUrl + '">');
  49. jQuery.get(href, function(data) {
  50. var $page = jQuery(data),
  51. $child = jQuery('.nestedlisting > .comment > .child', $page);
  52. $span
  53. .parentsUntil('.comment')
  54. .last()
  55. .replaceWith($child);
  56. });
  57. return false;
  58. });
  59. });
  60. },
  61. rootNode: document.body,
  62. queries: [
  63. { element: 'span.deepthread' }
  64. ]
  65. });

QingJ © 2025

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