From b4ce866006e835e55f91426e2957d1ec24b72e91 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 22 Mar 2020 16:28:11 +0100 Subject: Add an init function Delegate to the appropriate function based on the current site. --- godoc-links.user.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/godoc-links.user.js b/godoc-links.user.js index 6222cdb..0543fc4 100644 --- a/godoc-links.user.js +++ b/godoc-links.user.js @@ -1,3 +1,14 @@ +function init () { + switch (window.location.hostname) { + case 'godoc.org': + godoc(); + case 'pkg.go.dev': + pkg_go_dev(); + case 'github.com': + github(); + } +} + // Make the 'import "..."' package name a link to the package source. function godoc () { document.body.innerHTML = document.body.innerHTML @@ -51,3 +62,6 @@ function github_add_godoc_link () { function github_package_name () { return window.location.href.split('/').slice(2, 5).join('/'); } + + +init(); -- cgit v1.2.3