Skip to content

Instantly share code, notes, and snippets.

@dahlia
Last active December 10, 2018 01:23
Show Gist options
  • Save dahlia/1912c2dd9d86fa3aabca37d3acc041ea to your computer and use it in GitHub Desktop.
Save dahlia/1912c2dd9d86fa3aabca37d3acc041ea to your computer and use it in GitHub Desktop.
Redirect to Canonical Postgres Docs

Redirect to Canonical Postgres Docs

This userscript makes you to always see the canonical ("current") version of PostgreSQL docs instead of the specific (usually outdated) version of that.

Install

Distributed under public domain.

// ==UserScript==
// @name Redirect to Canonical Postgres Docs
// @namespace https://gist.github.com/dahlia/1912c2dd9d86fa3aabca37d3acc041ea
// @description Always show canonical Postgres docs
// @match https://postgresql.org/docs/*.*/static/*
// @match http://postgresql.org/docs/*.*/static/*
// @match https://www.postgresql.org/docs/*.*/static/*
// @match http://www.postgresql.org/docs/*.*/static/*
// @exclude https://www.postgresql.org/docs/current/static/*
// @version 2
// @grant none
// ==/UserScript==
(function () {
var m = location.pathname.match(/^\/docs\/\d+\.\d+\/static\/(.*)$/);
if (m !== null) {
var prefix = 'https://www.postgresql.org/docs/current/static/',
suffix = m[1] + location.search + location.hash;
location.href = prefix + suffix;
}
})();
@kanghyojun
Copy link

kanghyojun commented Dec 10, 2018

// ==UserScript==
// @name        Redirect to Canonical Postgres Docs
// @namespace   https://gist.github.com/dahlia/1912c2dd9d86fa3aabca37d3acc041ea
// @description Always show canonical Postgres docs
// @match       https://www.postgresql.org/docs/*.*/*
// @match       http://www.postgresql.org/docs/*/*
// @match       https://www.postgresql.org/docs/*/*
// @exclude     https://www.postgresql.org/docs/current/*
// @version     2
// @grant       none
// ==/UserScript==

(function () {
  var m = location.pathname.match(/^\/docs\/\d+\.?\d*\/(.*)$/);
  if (m !== null) {
    var prefix = 'https://www.postgresql.org/docs/current/',
        suffix = m[1] + location.search + location.hash;
    location.href = prefix + suffix;
  }
})();

After pg 10 released, this script has to be updated! And I think that there is some modification on URL of PostgreSQL documentation. (/static was removed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment