Greasy Fork is available in English.

NeteaseMusic UI Unlocker

Simple UI Unblock for Netease cloud music Website

  1. // ==UserScript==
  2. // @name NeteaseMusic UI Unlocker
  3. // @namespace https://github.com/nondanee
  4. // @version 0.3.0
  5. // @description Simple UI Unblock for Netease cloud music Website
  6. // @author nondanee
  7. // @match https://music.163.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. /* Refer to JixunMoe/cuwcl4c
  13. https://github.com/JixunMoe/cuwcl4c/blob/master/src/site/music.163.ts */
  14.  
  15. (() => {
  16. const search = (object, pattern) => {
  17. let result = null
  18. Object.keys(object)
  19. .some(key => {
  20. if (!object[key]) return
  21. else if (typeof object[key] === 'function') {
  22. result = String(object[key]).match(pattern) ? [key] : null
  23. }
  24. else if (typeof object[key] === 'object') {
  25. const inner = search(object[key], pattern)
  26. result = inner ? [key].concat(inner) : null
  27. }
  28. return !!result
  29. })
  30. return result
  31. }
  32.  
  33. const attach = (object, path, property) => {
  34. path = path.slice()
  35. let poiner = object
  36. const last = path.pop()
  37. path.forEach(key => {
  38. if (!(key in poiner)) throw new Error('KeyError')
  39. poiner = poiner[key]
  40. })
  41. return property ? poiner[last] = property : poiner[last]
  42. }
  43.  
  44. if (window.top != window.self) { // in iframe
  45. const pathOne = search(window.nej, '\\.dataset;if')
  46. const pathTwo = search(window.nm, '\\.copyrightId==')
  47. const pathThree = search(window.nm, '\\.privilege;if')
  48. const functionOne = attach(window.nej, pathOne)
  49.  
  50. attach(window.nej, pathOne, (z, name) => {
  51. if (name == 'copyright' || name == 'resCopyright') return 1
  52. return functionOne(z, name)
  53. })
  54. attach(window.nm, pathTwo, () => false)
  55. attach(window.nm, pathThree, song => {
  56. song.status = 0
  57. if (song.privilege) song.privilege.pl = 320000
  58. return 0
  59. })
  60.  
  61. Array.from(document.getElementsByClassName('js-dis'))
  62. .forEach(element => element.classList.remove('js-dis'))
  63.  
  64. const operation = document.getElementById('content-operation')
  65. if (operation) {
  66. const songId = operation.dataset.rid
  67. const disabledButton = operation.getElementsByClassName('u-btni-play-dis')[0]
  68. if (disabledButton) disabledButton.outerHTML = `
  69. <a data-res-action="play" data-res-id="${songId}" data-res-type="18" href="javascript:;" class="u-btn2 u-btn2-2 u-btni-addply f-fl" hidefocus="true" title="播放"><i><em class="ply"></em>播放</i></a>
  70. <a data-res-action="addto" data-res-id="${songId}" data-res-type="18" href="javascript:;" class="u-btni u-btni-add" hidefocus="true" title="添加到播放列表"></a>
  71. `
  72. }
  73. }
  74. })()