addStyle

add Style without GM_addStyle

Bu script direkt olarak kurulamaz. Başka scriptler için bir kütüphanedir ve meta yönergeleri içerir // @require https://update.greasyfork.org/scripts/410150/919980/addStyle.js

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

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 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          addStyle
// @namespace     https://greasyfork.org
// @version       0.3.4
// @description   add Style without GM_addStyle
// @match         *://*/*
// @grant         none
// ==/UserScript==

/**
 * Replace GM_addStyle;
 * Support external stylesheet path.
 * @param {String} inputCSS
 */
const addStyle = (inputCSS) => {
  let node;
  let css = inputCSS.trim();
  if (css.length === 0) return;
  if (css.includes('{') && css.includes('}')) {
    // Internal stylesheet
    node = document.createElement('style');
    node.appendChild(document.createTextNode(css));
  } else if (css.includes('.css')) {
    // External stylesheet
    node = document.createElement('link');
    node.rel = 'stylesheet';
    node.href = css;
  } else {
    console.error(`Function addStyle does't support input parameter: ${css}`);
  }
  const heads = document.getElementsByTagName('head');
  if (heads.length > 0) {
    heads[0].appendChild(node);
  } else {
    // No head yet, stick it whereever.
    document.documentElement.appendChild(node);
  }
};