Redirect Graphite.dev to Github

Redirects all Graphite.com PR links to Github

Fra og med 07.11.2025. Se den nyeste version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Redirect Graphite.dev to Github
// @namespace    https://app.graphite.dev/
// @version      2025-11-07
// @description  Redirects all Graphite.com PR links to Github
// @author       Jared Allard <[email protected]>
// @license      GPL-3.0
// @match        http*://app.graphite.com/github/pr/*
// @match        http*://app.graphite.dev/github/pr/*
// @run-at       document-start
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

// Example URL: https://app.graphite.dev/github/pr/org/repo/number

(function() {
    'use strict';

    const u = new URL(window.location.href)
    if(!u) {
        console.error(`failed to parse current location as a URL: ${window.location.href}`)
        return
    }

    // github/pr/gathertown/gather-town-v2/13844
    const values = u.pathname.split("/")
    if (values.length < 6) {
        console.error("split path was unexpected value", u)
        return
    }

    const vcs_provider = values[1]
    const link_type    = values[2]
    const org          = values[3]
    const repo         = values[4]
    const id           = values[5]

    let new_url = '';
    if (vcs_provider !== "github") {
        console.error(`unexpected VCS provider: ${vcs_provider}`)
        return
    }
    if(link_type !== "pr") {
        console.error(`unexpected type: ${link_type}`)
        return
    }

    new_url += `https://github.com/${org}/${repo}/pull/${id}`

    console.log("Redirecting Graphite -> Github", new_url)
    window.location.replace(new_url)
})();