Bandcamp: I'm Not A Fan

Removes playback limitation and dialog "The time has come to open thy heart/wallet"

当前为 2022-05-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bandcamp: I'm Not A Fan
  3. // @name:ru Bandcamp: Я не фанат
  4. // @description Removes playback limitation and dialog "The time has come to open thy heart/wallet"
  5. // @description:ru Снимает ограничение воспроизведений и убирает диалог "Пришло время открыть свое сердце/кошелек"
  6. // @namespace bc-inotafan.user.js
  7. // @version 1.1.1
  8. // @license MIT
  9. // @author askornot
  10. // @icon https://s4.bcbits.com/img/favicon/safari-pinned-tab.svg
  11. // @match https://*.bandcamp.com/*
  12. // @homepageURL https://greasyfork.org/ru/scripts/438039-bandcamp-i-m-not-a-fan
  13. // @supportURL https://greasyfork.org/ru/scripts/438039-bandcamp-i-m-not-a-fan/feedback
  14. // @grant none
  15. // @run-at document-end
  16. // @compatible chrome Violentmonkey 2.13.0
  17. // @compatible firefox Greasemonkey 4.11
  18. // @compatible firefox Violentmonkey 2.13.0
  19. // ==/UserScript==
  20.  
  21. function inject() {
  22. 'use strict';
  23.  
  24. const first = (a) => a[0];
  25.  
  26. const uncap = (o) => (o.is_capped = false);
  27.  
  28. const protect = (...namespaces) => {
  29. for (const namespace of namespaces) {
  30. const names = Object.keys(namespace);
  31. for (const name of names) {
  32. const target = namespace[name];
  33. Object.freeze(target);
  34. }
  35. }
  36. };
  37.  
  38. const patch = (...args) => {
  39. const data = first(args);
  40. if (typeof data === 'object') {
  41. data.trackinfo.map(uncap);
  42. data.is_purchased = true;
  43. data.play_cap_data = {
  44. streaming_limits_enabled: false,
  45. streaming_limit: Infinity,
  46. };
  47. protect(data);
  48. }
  49. };
  50.  
  51. if (Player === void 0) return;
  52.  
  53. const target = 'init';
  54.  
  55. const descriptor = Object.getOwnPropertyDescriptor(Player, target);
  56. if (descriptor === void 0) {
  57. throw new Error(`Failed extract "${target}" descriptor of "Player"!`);
  58. }
  59.  
  60. Object.defineProperty(Player, target, {
  61. ...descriptor,
  62. value: function () {
  63. patch(...arguments);
  64. return descriptor.value.apply(this, arguments);
  65. },
  66. });
  67. }
  68.  
  69. (function (source) {
  70. const script = document.createElement('script');
  71. script.type = 'text/javascript';
  72. script.textContent = '(' + source.toString() + ')()';
  73. const target =
  74. document.getElementsByTagName('head')[0] ||
  75. document.body ||
  76. document.documentElement;
  77. target.appendChild(script);
  78. })(inject);