Last active
November 10, 2018 02:56
-
-
Save devinacker/92211403b3674487218a07bafcfb0907 to your computer and use it in GitHub Desktop.
Revisions
-
devinacker revised this gist
Oct 4, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,7 @@ var itemlist = node.getElementsByClassName("item-list")[0]; if (itemlist == null) return; delete itemlist._statusObserver; } }); }); -
devinacker revised this gist
Oct 4, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @description keep timeline from automatically scrolling under mouse cursor // @author @revenant@mastodon.social // @version 0.1 // @include https://mastodon.social/* // @run-at document-idle // @namespace revenant.mastodon // ==/UserScript== -
devinacker revised this gist
Oct 4, 2018 . 1 changed file with 15 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,55 +14,48 @@ // watch for added/removed child nodes for selected nodes and all child nodes var observerInit = { childList: true, subtree: true }; // callback for when a status (or something else) is added to a timeline var columnModified = function(recs) { recs.forEach(function (rec) { // keep the timeline scrolled down to the same spot var scrollable = rec.target.closest(".scrollable"); if (scrollable !== null && scrollable.scrollTop === 0) { rec.addedNodes.forEach(function(node) { scrollable.scrollTop += node.scrollHeight; }); } }); }; // watch for timelines being shown/hidden new MutationObserver(function(recs) { recs.forEach(function (rec) { rec.addedNodes.forEach(function (node) { if (node.className == "column") { var itemlist = node.getElementsByClassName("item-list")[0]; if (itemlist == null) return; itemlist._statusObserver = new MutationObserver(columnModified); // monitor a timeline if the user puts the mouse over it itemlist.addEventListener("mouseenter", function() { itemlist._statusObserver.observe(itemlist, { childList: true }); }); // stop monitoring that timeline when the cursor leaves itemlist.addEventListener("mouseleave", function() { itemlist._statusObserver.disconnect(); }); } }); rec.removedNodes.forEach(function (node) { if (node.className == "column") { var itemlist = node.getElementsByClassName("item-list")[0]; if (itemlist == null) return; delete node._statusObserver; } }); }); }).observe(document.getElementsByClassName("columns-area")[0], observerInit); -
devinacker created this gist
Oct 4, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ // ==UserScript== // @name Mastodon timeline thing // @description keep timeline from automatically scrolling under mouse cursor // @author @revenant@mastodon.social // @version 0.1 // @match https://mastodon.social/* // @run-at document-idle // @namespace revenant.mastodon // ==/UserScript== (function () { "use strict"; // watch for added/removed child nodes for selected nodes and all child nodes var observerInit = { childList: true, subtree: true }; // callback for when a status (or something else) is added to a timeline var columnModified = function(recs) { recs.forEach(function (rec) { // keep the timeline scrolled down to the same spot var scrollable = rec.target.closest(".scrollable"); if (scrollable !== null && scrollable.scrollTop === 0) { rec.addedNodes.forEach(function(node) { // console.log("scroll height updated"); scrollable.scrollTop += node.scrollHeight; }); } }); }; // watch for timelines being shown/hidden new MutationObserver(function(recs) { recs.forEach(function (rec) { rec.addedNodes.forEach(function (node) { //console.log(node.className); if (node.className == "column") { var itemlist = node.getElementsByClassName("item-list")[0]; //console.log(itemlist); if (itemlist == null) return; //console.log("column added"); itemlist._statusObserver = new MutationObserver(columnModified); // monitor a timeline if the user puts the mouse over it itemlist.addEventListener("mouseenter", function() { //console.log("mouse entered scrollable"); itemlist._statusObserver.observe(itemlist, { childList: true }); }); // stop monitoring that timeline when the cursor leaves itemlist.addEventListener("mouseleave", function() { //console.log("mouse exited scrollable"); itemlist._statusObserver.disconnect(); }); } }); rec.removedNodes.forEach(function (node) { if (node.className == "column") { var itemlist = node.getElementsByClassName("item-list")[0]; if (itemlist == null) return; console.log("column removed"); delete node._statusObserver; } }); }); }).observe(document.getElementsByClassName("columns-area")[0], observerInit); })();