Fix image loading

Fixes images not loading by using another server

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        Fix image loading
// @namespace   Violentmonkey Scripts
// @match       https://readmanganato.com/manga*/*
// @match       https://mangakakalot.com/chapter/*
// @grant       none
// @version     1.6
// @author      Ost
// @description Fixes images not loading by using another server
// ==/UserScript==

// Default
changeServer(5);


function changeServer(server) {
  console.log("Switching servers to " + server)
  var regex = /(https:\/\/s\d*\.mkklcdnv\d*\.com)(.*)/gm;
  img = document.getElementsByTagName('img');
  for (var i = 0; i < img.length; i++) {
      img[i].src = img[i].src.replace(regex, "https://s"+server+".mkklcdnv"+server+".com$2");
  }
}

if (document.getElementsByClassName("server-image-caption")[0]){
  var caption = document.getElementsByClassName("server-image-caption")[0];
}
else {
  var caption = document.getElementsByClassName("option_wrap")[0];
}

var innerDiv = document.createElement('div');
innerDiv.className = "server-image-name";
innerDiv.innerHTML = "Additional image servers: "
caption.appendChild(innerDiv);

var i;
for (i = 0; i < 10; i++) {
  var child = document.createElement('button');
  //child.className = "server-image-btn isactive";
  child.className = "real-server";
  child.innerHTML = (i+1).toString();
  child.style.backgroundColor = "#27ae60";
  child.style.color = "white";
  child.style.padding = "6px 12px";
  child.style.margin = "4px 2px";
  child.style.cursor = "pointer";
  child.style.border = "none";
  child.onclick = function(){changeServer(this.innerHTML);};
  innerDiv.appendChild(child);
}

console.log("if image loading fails set network.http.referer.spoofSource to false");
console.log("if no referers are sent try setting network.http.referer.XOriginPolicy to 0");