From 9c8e2e0e004fd825ea6a2537c2099b2a89e4a70a Mon Sep 17 00:00:00 2001 From: Joseph Frazier <1212jtraceur@gmail.com> Date: Thu, 1 Sep 2016 17:36:49 -0400 Subject: [PATCH] Fall back to if #js-repo-pjax-container is missing This allows this module to be used with [Turbolinks] sites like GitLab. For a demo: * Visit https://gitlab.com/gitlab-org/gitlab-ce * Paste the contents of this file into the console * Paste the following into the console: ```javascript gitHubInjection(window, function(err) { if (err) { return console.error(err); } console.warn("XXX INJECTION"); }); ``` * Click the "Activity" link * Notice "XXX INJECTION" printed to the console [Turbolinks]: https://github.com/turbolinks/turbolinks See https://github.com/OctoLinker/browser-extension/issues/113 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 2d4743c..86cc41e 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ var gitHubInjection = function (global, cb) { throw new Error('Callback is not a function'); } - var domElement = global.document.getElementById('js-repo-pjax-container'); + var domElement = global.document.getElementById('js-repo-pjax-container') || global.document.documentElement; if (!domElement || !global.MutationObserver) { return cb(null); }