Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hyOzd/b10e9d90622b034b0e05 to your computer and use it in GitHub Desktop.

Select an option

Save hyOzd/b10e9d90622b034b0e05 to your computer and use it in GitHub Desktop.

Revisions

  1. hyOzd revised this gist Feb 14, 2016. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions unfix-all-the-toolbars.user.js
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,8 @@ function unfixAll() {
    /* Avoid unfixing JavaScript popups like Twitter's "confirm retweet" window */
    {
    fixed_items.push(el);
    el.style.position = "static";
    //el.style.position = "static";
    el.style.visibility = "hidden";
    /* I tried using "absolute" in the past, but this breaks WordPress's footer.
    Using "static" breaks it too, but at least it doesn't get in the way. */
    }
    @@ -35,7 +36,8 @@ function fixBack()
    Array.forEach(
    fixed_items,
    function(el) {
    el.style.position = "fixed";
    //el.style.position = "fixed";
    el.style.visibility = "";
    }
    )
    fixed_items = [];
  2. hyOzd revised this gist Jan 2, 2016. 1 changed file with 30 additions and 3 deletions.
    33 changes: 30 additions & 3 deletions unfix-all-the-toolbars.user.js
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,56 @@
    // ==UserScript==
    // @name unfix-all-the-toolbars
    // @description Removes "position: fixed" style from elements, unfixing "toolbars" and the such.
    // @namespace http://inf.ufrgs.br/~vbuaraujo/
    // @namespace https://hasanyavuz.ozderya.net
    // @include *
    // @version 1
    // @grant none
    // ==/UserScript==


    // Based on https://stackoverflow.com/questions/13696100/greasemonkey-script-to-make-fixed-positioned-elements-static
    // and https://gist.github.com/vbuaraujo/bddb3b93a0b2b7e28e1b

    fixed_items = [];

    function unfixAll() {
    Array.forEach(
    document.querySelectorAll("h1, h2, ul, ol, li, div, nav, header, footer"),
    function (el) {
    var style = window.getComputedStyle(el);
    if (style.position === "fixed" &&
    if (style.position === "fixed" && style.top == "0px" &&
    !(style.display === "none" || style.visibility === "hidden"))
    /* Avoid unfixing JavaScript popups like Twitter's "confirm retweet" window */
    {
    fixed_items.push(el);
    el.style.position = "static";
    /* I tried using "absolute" in the past, but this breaks WordPress's footer.
    Using "static" breaks it too, but at least it doesn't get in the way. */
    }
    });
    }

    window.addEventListener("load", unfixAll);
    function fixBack()
    {
    Array.forEach(
    fixed_items,
    function(el) {
    el.style.position = "fixed";
    }
    )
    fixed_items = [];
    }

    function onScroll()
    {
    if (window.scrollY > 0)
    {
    unfixAll();
    }
    else
    {
    fixBack();
    }
    }

    window.addEventListener("scroll", onScroll);
  3. @vbuaraujo vbuaraujo revised this gist Feb 17, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion unfix-all-the-toolbars.user.js
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ function unfixAll() {
    var style = window.getComputedStyle(el);
    if (style.position === "fixed" &&
    !(style.display === "none" || style.visibility === "hidden"))
    /* Avoid unfixing JavaScript popus like Twitter's "confirm retweet" window */
    /* Avoid unfixing JavaScript popups like Twitter's "confirm retweet" window */
    {
    el.style.position = "static";
    /* I tried using "absolute" in the past, but this breaks WordPress's footer.
  4. @vbuaraujo vbuaraujo created this gist Feb 17, 2015.
    29 changes: 29 additions & 0 deletions unfix-all-the-toolbars.user.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    // ==UserScript==
    // @name unfix-all-the-toolbars
    // @description Removes "position: fixed" style from elements, unfixing "toolbars" and the such.
    // @namespace http://inf.ufrgs.br/~vbuaraujo/
    // @include *
    // @version 1
    // @grant none
    // ==/UserScript==


    // Based on https://stackoverflow.com/questions/13696100/greasemonkey-script-to-make-fixed-positioned-elements-static

    function unfixAll() {
    Array.forEach(
    document.querySelectorAll("h1, h2, ul, ol, li, div, nav, header, footer"),
    function (el) {
    var style = window.getComputedStyle(el);
    if (style.position === "fixed" &&
    !(style.display === "none" || style.visibility === "hidden"))
    /* Avoid unfixing JavaScript popus like Twitter's "confirm retweet" window */
    {
    el.style.position = "static";
    /* I tried using "absolute" in the past, but this breaks WordPress's footer.
    Using "static" breaks it too, but at least it doesn't get in the way. */
    }
    });
    }

    window.addEventListener("load", unfixAll);