aboutsummaryrefslogtreecommitdiff
path: root/utils/imageUtils.js
blob: 56c98fb685ff9e553acec235b70e2382972fa55d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export function getHeaders(providerId) {
  switch (providerId) {
    case "mangahere":
      return { Referer: "https://mangahere.org" };
    case "mangadex":
      return { Referer: "https://mangadex.org" };
    case "mangakakalot":
      return { Referer: "https://mangakakalot.com" };
    case "mangapill":
      return { Referer: "https://mangapill.com" };
    case "mangasee123":
      return { Referer: "https://mangasee123.com" };
    case "comick":
      return { Referer: "https://comick.app" };
    default:
      return null;
  }
}

export function getRandomId() {
  return Math.random().toString(36).substr(2, 9);
}

export function truncateImgUrl(url) {
  // Find the index of .png if not found find the index of .jpg
  let index =
    url.indexOf(".png") !== -1 ? url.indexOf(".png") : url.indexOf(".jpg");
  if (index !== -1) {
    // If .png is found
    url = url.slice(0, index + 4); // Slice the string from the start to the index of .png plus 4 (the length of .png)
  }
  return url;
}