Bandcamp: I'm Not A Fan

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

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

  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.0
  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 (source) {
  22. const script = document.createElement('script');
  23. script.type = 'text/javascript';
  24. script.textContent = '(' + source.toString() + ')()';
  25. const target =
  26. document.getElementsByTagName('head')[0] ||
  27. document.body ||
  28. document.documentElement;
  29. target.appendChild(script);
  30. })(function () {
  31. 'use strict';
  32.  
  33. const first = (a) => a[0];
  34.  
  35. const uncap = (o) => (o.is_capped = false);
  36.  
  37. const protect = (...namespaces) => {
  38. for (const namespace of namespaces) {
  39. const names = Object.keys(namespace);
  40. for (const name of names) {
  41. const target = namespace[name];
  42. Object.freeze(target);
  43. }
  44. }
  45. };
  46.  
  47. const createPatch = (...args) => {
  48. const data = first(args);
  49. if (typeof data === 'object') {
  50. data.trackinfo.map(uncap);
  51. data.play_cap_data = {
  52. streaming_limits_enabled: false,
  53. streaming_limit: Infinity,
  54. };
  55. data.is_purchased = true;
  56. protect(data);
  57. }
  58. };
  59.  
  60. if (Player === void 0) return;
  61.  
  62. const target = 'init';
  63. const proto = Player;
  64.  
  65. const descriptor = Object.getOwnPropertyDescriptor(proto, target);
  66.  
  67. Object.defineProperty(proto, target, {
  68. ...descriptor,
  69. value: function () {
  70. createPatch(...arguments);
  71. return descriptor.value.apply(this, arguments);
  72. },
  73. });
  74. });