Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ireade's full-sized avatar

Ire Aderinokun ireade

View GitHub Profile
@ireade
ireade / sw.js
Last active October 7, 2023 20:56
Handle broken images with the service worker
self.addEventListener('install', (e) => {
e.waitUntil(
caches.open("precache").then((cache) => cache.add("/broken.png"))
);
});
function isImage(fetchRequest) {
return fetchRequest.method === "GET" && fetchRequest.destination === "image";
}
@ireade
ireade / opera-mini-detect.js
Last active February 27, 2020 22:26
Detect if Opera Mini/Mobile is in Extreme or High Savings Mode
// Check if current browser is Opera
var isOpera = window.opera | window.opr | ( navigator.userAgent.indexOf(' OPR/') > -1 ) | ( navigator.userAgent.indexOf(' Coast/') > -1 ) | ( navigator.userAgent.indexOf(' OPiOS/') > -1 );
// Check if the Opera browser is Opera Mini or Opera Mobile in regular mode (called High Savings Mode)
var isOperaHigh = (navigator.userAgent.indexOf('OPR/') > -1) && (navigator.userAgent.indexOf('Mobile') > -1) && (navigator.userAgent.indexOf('Presto/') < 0);
// Check if the Opera browser is Opera Mini in Extreme Savings Mode
var isOperaExtreme = (navigator.userAgent.indexOf('Opera Mini/') > -1) && (navigator.userAgent.indexOf('Presto/') > -1);
$(document).ready(function(){
// required vars
var accessToken = window.location.hash.split("=")[1];
var userID = accessToken.split(".")[0];
// step 1: get users followed
getFollowedUsers(userID, accessToken, function(followed_users){
// step 2a: check for non-mutual follows