Pixeldrain show video even without logged

Show video even without logged in pixeldrain

当前为 2025-02-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Pixeldrain show video even without logged
  3. // @namespace https://greasyfork.org/users/821661
  4. // @match https://pixeldrain.com/*
  5. // @grant GM.registerMenuCommand
  6. // @version 1.1.3
  7. // @require https://update.greasyfork.org/scripts/526417/1540623/USToolkit.js
  8. // @run-at document-start
  9. // @author hdyzen
  10. // @description Show video even without logged in pixeldrain
  11. // @license GPL-3.0-only
  12. // ==/UserScript==
  13.  
  14. function commands() {
  15. const useBypassUrl = JSON.parse(localStorage.getItem("bypass-url"));
  16.  
  17. if (useBypassUrl) bypassVideoUrl();
  18.  
  19. GM.registerMenuCommand(`Use bypass src: [${useBypassUrl ? "ON" : "OFF"}]`, e => {
  20. if (useBypassUrl || confirm("This use bypassed url (the video may slow down or not load). Are you sure?")) {
  21. localStorage.setItem("bypass-url", !useBypassUrl);
  22. window.location.reload();
  23. }
  24. });
  25. }
  26. commands();
  27.  
  28. function bypassVideoUrl() {
  29. const handleMutations = () => {
  30. const source = document.querySelector("source[src^='/api/']");
  31.  
  32. if (source) source.src = source.src.replace("https://pixeldrain.com/api/file/", "https://pd.cybar.xyz/");
  33. };
  34.  
  35. const observer = new MutationObserver(handleMutations);
  36.  
  37. observer.observe(document.body || document.documentElement, {
  38. childList: true,
  39. subtree: true,
  40. });
  41. }
  42.  
  43. Object.defineProperty(unsafeWindow, "viewer_data", {
  44. get: () => _viewer_data,
  45. set: value => {
  46. const files = value?.api_response?.files;
  47.  
  48. if (files) {
  49. for (const file of value.api_response.files) {
  50. console.log(file);
  51. file.allow_video_player = true;
  52. }
  53. } else {
  54. value.api_response.allow_video_player = true;
  55. value.api_response.availability = "";
  56. }
  57.  
  58. _viewer_data = value;
  59. },
  60. });