Skip to content

Instantly share code, notes, and snippets.

@stuartphilp
Last active February 27, 2018 16:29
Show Gist options
  • Select an option

  • Save stuartphilp/a8e3f989c1d0364b876db7b45bf745a1 to your computer and use it in GitHub Desktop.

Select an option

Save stuartphilp/a8e3f989c1d0364b876db7b45bf745a1 to your computer and use it in GitHub Desktop.

Revisions

  1. stuartphilp renamed this gist Feb 27, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. stuartphilp created this gist Feb 27, 2018.
    26 changes: 26 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    // ==UserScript==
    // @name ScrollingBugTitlez
    // @description Pins the bug title header and other useful context so it's always visible when scrolling longer bugs
    // @include https://bugzilla.mozilla.org/show_bug.cgi?id=*
    // @author Stuart Philp
    // ==/UserScript==

    /*
    Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/licenses/publicdomain/
    */


    var bugzillaBody = document.querySelector("#bugzilla-body");
    var elementPosition = document.querySelector("section.module");
    bugzillaBody.addEventListener('scroll', function() {
    var rect = elementPosition.getBoundingClientRect();
    if (bugzillaBody.scrollTop > rect.top) {
    elementPosition.style.position = "fixed";
    elementPosition.style.width = "100%";
    elementPosition.style.left = 0;
    elementPosition.style.top = '44px';
    } else {
    elementPosition.style.position = "static";
    }
    });