PageSourceSearch

https://openaudible.org/scripts/index.js

js openaudible.org collected 2026-10-02 05:55:28 UTC 3,383 bytes, 132 lines download raw bytes

1// Returns:
2// 0: Windows
3// 1: Mac
4// 2: Linux
5// -1: unknown or mobile
6
7function getOperatingSystem() {
8  var userAgent = window.navigator.userAgent;
9  var platform = window.navigator.platform;
10  var macosPlatforms = ["Macintosh", "MacIntel", "MacPPC", "Mac68K"];
11  var windowsPlatforms = ["Win32", "Win64", "Windows", "WinCE"];
12  var iosPlatforms = ["iPhone", "iPad", "iPod"];
13  var os = null;
14
15  if (macosPlatforms.indexOf(platform) !== -1) {
16    os = "mac";
17  } else if (iosPlatforms.indexOf(platform) !== -1) {
18    os = "mac";
19  } else if (windowsPlatforms.indexOf(platform) !== -1) {
20    os = "win";
21  } else if (/Android/.test(userAgent)) {
22    os = "win";
23  } else if (!os && /Linux/.test(platform)) {
24    os = "lin";
25  } else {
26    os = "unk";
27  }
28  return os;
29}
30
31function setScreenshot() {
32  var os = getOperatingSystem();
33  const urlParams = new URLSearchParams(window.location.search);
34  const platform = urlParams.get("platform");
35  if (platform) os = platform;
36
37  if (os === "mac") {
38    const image = "screenshots/mac/main_window.png"
39    document.getElementById("screenshot_image").src = image;
40  }
41}
42
43// const toggleLinuxDistributionDownloadLink = () => {
44//   const container = document.getElementById("linux-dropdown-wrapper");
45
46//   if (!container.classList.contains("active")) {
47//     container.classList.add("active");
48//     container.style.height = "auto";
49
50//     let height = container.clientHeight + "px";
51
52//     container.style.height = "0px";
53
54//     setTimeout(function () {
55//       container.style.height = height;
56//     }, 0);
57//   } else {
58//     container.style.height = "0px";
59
60//     container.addEventListener(
61//       "transitionend",
62//       function () {
63//         container.classList.remove("active");
64//       },
65//       {
66//         once: true,
67//       }
68//     );
69//   }
70// };
71
72const toggleLinuxDistributionDownloadLink = (show) => {
73  const container = document.getElementsByClassName("linux-dropdown-wrapper");
74  if (show) {
75    container.style.display = "block";
76  } else {
77    container.style.display = "none";
78  }
79};
80
81function initYoutube() {
82  let videoContainer = document.getElementById("videoContainer");
83
84  videoContainer.addEventListener("click", function () {
85    var videoId = this.getAttribute("data-video");
86    var iframe = document.createElement("iframe");
87    iframe.setAttribute(
88      "src",
89      "https://www.youtube.com/embed/" + videoId + "?autoplay=1&rel=0"
90    );
91    iframe.setAttribute("allowfullscreen", "");
92    iframe.setAttribute("allow", "autoplay");
93    iframe.style.width = "100%";
94    iframe.style.height = "100%";
95    this.innerHTML = "";
96    this.appendChild(iframe);
97    this.classList.add("played");
98  });
99}
100
101const toggleElementVisibility = (elementId, show) => {
102  const element = document.getElementById(elementId);
103  if (show) {
104    element.style.display = "block";
105  } else {
106    element.style.display = "none";
107  }
108};
109
110// Client-side UTM parameter removal
111function clean_utm() {
112  const url = new URL(window.location);
113  let hasUTM = false;
114
115  if (url.searchParams.has('utm_source')) {
116    url.searchParams.delete('utm_source');
117    hasUTM = true;
118  }
119
120  if (hasUTM) {
121    window.history.replaceState({}, document.title, url.toString());
122  }
123}
124
125const onInit = () => {
126  setScreenshot();
127  initYoutube();
128};
129
130document.addEventListener("DOMContentLoaded", onInit, false);
131
132clean_utm();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.