Greasy Fork is available in English.

Add Raw link To GitHub Files

12/13/2023, 1:18:04 AM

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Add Raw link To GitHub Files
// @namespace   Violentmonkey Scripts
// @match       https://github.com/*
// @version     0.0.2
// @description 12/13/2023, 1:18:04 AM
// @grant       GM_addStyle
// @license     MIT
// ==/UserScript==

const cssText = `

    @keyframes button384 {
        from{
            background-position-x: 1px;
        }
        to{
            background-position-x: 2px;
        }
    }
    [aria-label="Copy file name to clipboard"]:not([ls4yu]) {
        animation: button384 1ms linear 0s 1 normal forwards;
    }

    .button385 {
      margin: 4px 2px;
    }

`;
function f101(btn) {
  btn.setAttribute('ls4yu', '');
  let p = btn;
  let link;
  while ((p = p.parentNode) instanceof HTMLElement) {
    link = p.querySelector('a[href*="#diff-"]');
    if (link) {
      break;
    }
  }
  if (!link) return;
  p = link.parentElement;
  if (!p) return;


  if (p.querySelector('.button385')) return;

  const code = link.querySelector('code');
  if (!code) return;
  const text = code.textContent.trim().replace(decodeURIComponent('%E2%80%8E'), '').trim();


  let commitId = '';

  const m = /\/([\w\-]+)\/([\w\-]+)\/commit\/([0-9a-f]{40})(#|$)/.exec(location.pathname);

  if (m && m[3]) {
    commitId = m[3];
  }

  if (commitId) {

    const a = document.createElement('a');
    a.classList.add('button385');
    p.insertBefore(a, link);

    a.textContent = 'RAW';
    a.style.cursor = 'pointer';




    a.setAttribute('href', `https://github.com/${m[1]}/${m[2]}/raw/${commitId}/${text}`)

  }

}


document.addEventListener('animationstart', (evt) => {
  const animationName = evt.animationName;
  if (!animationName) return;
  if (animationName === 'button384') {
    f101(evt.target);
  }
}, { passive: true, capture: true });

GM_addStyle(cssText);