Item Guide Image URL Fixer

fix old broken item image URLs

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

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

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

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

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

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name     Item Guide Image URL Fixer
// @description fix old broken item image URLs
// @version  1.0.0
// @match		 https://www.gaiaonline.com/forum/compose/entry/new/*
// @match		 https://www.gaiaonline.com/forum/compose/entry/*_*/
// @grant    none
// @namespace https://greasyfork.org/users/2263
// ==/UserScript==

var oldDomain = /gaia.hs.llnwd.net\/e1/g;
var curDomain = 'graphics.gaiaonline.com';
var buttons = document.querySelector('.form_buttons');
var button = document.createElement('button');
button.type = 'button';
button.className = 'cta-button-sm';
button.innerHTML = '<span>Fix broken item image URLs</span>';
button.addEventListener('click', urlFixer);
buttons.insertBefore(document.createTextNode("\n"), buttons.children[0]);
buttons.insertBefore(button, buttons.childNodes[0]);

function urlFixer(evt) {
  var textarea = document.querySelector('#message');
  var text = textarea.value;
  
  var count = (text.match(oldDomain) || []).length;
  text = text.replace(oldDomain, curDomain);
  
  alert(`Replaced: ${count} domains`)
  
  textarea.value = text;
}