Last active
July 27, 2023 09:48
Revisions
-
azu revised this gist
Jul 27, 2023 . 1 changed file with 3 additions and 2 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 @@ -1,7 +1,7 @@ // ==UserScript== // @name Bluesky: auto refresh // @namespace https://efcl.info // @match https://bsky.app/* // @grant none // @version 1.0 // @author azu @@ -19,6 +19,7 @@ const addRefreshCallForPageVisible = (refreshFn) => { if (!document.hidden) { try { refreshFn(); document.querySelector('[aria-label="Load new posts"]')?.click(); } catch(error){ console.error("[GM] refresh function call is falled", { error @@ -28,7 +29,7 @@ const addRefreshCallForPageVisible = (refreshFn) => { } } }); }; window.setInterval = (fn, ms) => { if(isBskyRefresh(fn,ms)){ addRefreshCallForPageVisible(fn); // when page is shown, call refresh function -
azu created this gist
Jul 15, 2023 .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,37 @@ // ==UserScript== // @name Bluesky: auto refresh // @namespace https://efcl.info // @match https://bsky.app/notifications // @grant none // @version 1.0 // @author azu // @description Auto Refresh when notifications is shown // ==/UserScript== const origSetInterval = window.setInterval; // refresh 15sec === refresh fn const isBskyRefresh = (fn, ms) => { const source = fn.toString(); return source.includes(".updateSessionState()") && ms === 15e3; }; const addRefreshCallForPageVisible = (refreshFn) => { document.addEventListener("visibilitychange", () => { if (!document.hidden) { try { refreshFn(); } catch(error){ console.error("[GM] refresh function call is falled", { error }) } finally { console.log("[GM] call auto refresh") } } }); } window.setInterval = (fn, ms) => { if(isBskyRefresh(fn,ms)){ addRefreshCallForPageVisible(fn); // when page is shown, call refresh function } origSetInterval.call(this, fn, ms); };