Skip to content

Instantly share code, notes, and snippets.

@sj26
Last active June 10, 2021 01:58
Show Gist options
  • Save sj26/0c04accaaf2ec83b2deb79425f8046ca to your computer and use it in GitHub Desktop.
Save sj26/0c04accaaf2ec83b2deb79425f8046ca to your computer and use it in GitHub Desktop.
I use the heystack page as the root of my basecamp tab, and often want to read notifications then go back to the heystack with a trackpad swipe, but then the heystack contents is outdated because turblinks restores the previous contents. So this lets me stay on the trackpad and do a pull-to-refresh to update the notifications. Ideally it would r…
// ==UserScript==
// @name basecamp-pull-to-refresh
// @description Pull to refresh the Basecamp 3 Heystack page.
// @author Samuel Cochran <sj26@sj26.com>
// @license MIT
// @version 1
// @match https://3.basecamp.com/*/my/readings
// @run-at document-end
// @homepage https://gist.github.com/sj26/0c04accaaf2ec83b2deb79425f8046ca
// ==/UserScript==
(function() {
'use strict';
var toggled = false;
$(window).bind('scroll', function() {
if (window.scrollY < -20) {
toggled = true;
// Reset the progressbar value to zero, nothing else does this??
Turbolinks.controller.adapter.progressBar.value = 0;
// Show the progress bar, which also starts it trickling
Turbolinks.controller.adapter.progressBar.show();
} else if (window.scrollY >= 0 && toggled) {
toggled = false;
// Turbolinks will reload the page, and also show the progressbar again but that seems safe
Turbolinks.visit();
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment