Soundcloud Disable Comments

Remove comment elements from Soundcloud waveforms.

当前为 2014-04-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Soundcloud Disable Comments
  3. // @description Remove comment elements from Soundcloud waveforms.
  4. // @namespace http://userscripts.org/users/tim
  5. // @include http://soundcloud.com/*
  6. // @include https://soundcloud.com/*
  7. // @copyright 2012 Tim Smart
  8. // @license MIT. Full license in source code.
  9. // @version 0.0.1.20140425034613
  10. // ==/UserScript==
  11.  
  12. // The MIT License
  13. //
  14. // Copyright (c) 2012 Tim Smart
  15. //
  16. // Permission is hereby granted, free of charge, to any person obtaining a
  17. // copy of this software and associated documentation files
  18. // (the "Software"), to deal in the Software without restriction,
  19. // including without limitation the rights to use, copy, modify, merge,
  20. // publish, distribute, sublicense, and/or sell copies of the Software, and
  21. // to permit persons to whom the Software is furnished to do so, subject to
  22. // the following conditions:
  23. //
  24. // The above copyright notice and this permission notice shall be included
  25. // in all copies or substantial portions of the Software.
  26. //
  27. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  28. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  30. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  31. // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  32. // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  33. // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  34.  
  35. ;(function () {
  36.  
  37. // For multiple environments.
  38. var unsafe = unsafeWindow || window
  39. // Find a MutationObserver constructor.
  40. var MutationObserver = unsafe.MutationObserver
  41.  
  42. if (!MutationObserver && unsafe.WebKitMutationObserver) {
  43. MutationObserver = unsafe.WebKitMutationObserver
  44. }
  45.  
  46. // ====
  47. // Remove comments when found
  48.  
  49. function removeComments () {
  50. var commentBubbles = document.querySelectorAll('div.commentBubble')
  51. var commentPlaceholders = document.querySelectorAll('div.commentPlaceholder')
  52. var commentForms = document.querySelectorAll('div.commentForm')
  53. var wrappers = document.querySelectorAll('div.waveform__scene')
  54. var canvases = null
  55. var element = null
  56.  
  57. for (var i = 0, il = commentBubbles.length; i < il; i++) {
  58. element = commentBubbles[i]
  59. element.parentNode.removeChild(element)
  60. }
  61. for (var i = 0, il = commentPlaceholders.length; i < il; i++) {
  62. element = commentPlaceholders[i]
  63. element.parentNode.removeChild(element)
  64. }
  65. for (var i = 0, il = commentForms.length; i < il; i++) {
  66. element = commentForms[i]
  67. element.parentNode.removeChild(element)
  68. }
  69. for (var i = 0, il = wrappers.length; i < il; i++) {
  70. element = wrappers[i]
  71. canvases = element.querySelectorAll('canvas')
  72.  
  73. if (3 === canvases.length) {
  74. element = canvases[1]
  75. element.parentNode.removeChild(element)
  76. }
  77. }
  78. }
  79.  
  80. var observer = new MutationObserver(removeComments)
  81. observer.observe(document, { childList : true, subtree : true })
  82. removeComments()
  83.  
  84. })();
  85.  
  86. /* vim: set expandtab sts=2 ts=2 sw=2 tw=80 ft=javascript :*/