Graphite to GitHub Redirector

Redirects from graphite.dev GitHub PR page to GitHub's PR page

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Graphite to GitHub Redirector
// @namespace    http://tampermonkey.net/
// @version      0.1
// @license      MIT
// @description  Redirects from graphite.dev GitHub PR page to GitHub's PR page
// @author       Walker Hildebrand
// @match        https://app.graphite.dev/github/pr/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to extract information from the current URL
    function extractInfoFromURL() {
        const match = window.location.pathname.match(/^\/github\/pr\/([\w-]+)\/([\w-]+)\/(\d+)/);
        if (match) {
            const org = match[1];
            const repo = match[2];
            const prNumber = match[3];
            return { org, repo, prNumber };
        } else {
            console.log('Invalid URL format for GitHub PR.');
            return null;
        }
    }

    // Function to redirect to GitHub PR page
    function redirectToGitHub() {
        const info = extractInfoFromURL();
        if (info) {
            const { org, repo, prNumber } = info;
            const githubURL = `https://github.com/${org}/${repo}/pull/${prNumber}`;
            console.log('Redirecting to GitHub:', githubURL);
            window.location.href = githubURL;
        }
    }

    // Execute the redirect function when the page is loaded
    window.addEventListener('load', redirectToGitHub);
})();