Add GitHack Links To GitHub Files

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

2024-01-08 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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 GitHack Links To GitHub Files
// @namespace   Violentmonkey Scripts
// @match       https://github.com/*
// @grant       none
// @version     0.0.2
// @description 12/13/2023, 1:18:04 AM
// @grant       GM_addStyle
// @license     MIT
// ==/UserScript==

const cssText = `

    @keyframes rawButtonAppended {
        from{
            background-position-x: 1px;
        }
        to{
            background-position-x: 2px;
        }
    }
    [data-testid="raw-button"]:not([ls4yu]) {
        animation: rawButtonAppended 1ms linear 0s 1 normal forwards;
    }


`;
function f101(rawButton) {
  rawButton.setAttribute('ls4yu', '');
  const newButton = rawButton.cloneNode(true);
  newButton.innerHTML = newButton.innerHTML.replace('Raw', 'GitHack');
  const newURL = newButton.href.replace(/^https\:\/\/github.com\/([-\w]+)\/([-\w.]+)\/(blob|raw)\/([-\w\/\.]+)$/g,
    (_, u, r, x1, k) => `https://raw.githack.com/${u}/${r}/${k}`
  );
  newButton.href = newURL;
  rawButton.parentNode.insertBefore(newButton, rawButton.nextSibling);
}


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

GM_addStyle(cssText);