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 characters
| /** @preserve Based heavily on the work by Keith Grant (keithjgrant.com) **/ | |
| // IIFE to restrict global namespace | |
| (function(){ | |
| // link to the anonymous avatar | |
| const ANON_AVATAR = '/images/app-shell/mm.png'; | |
| // cloudinary app code (remember to restrict to set domains in settings) | |
| const CLOUD_CODE = 'dffhrhuy4'; | |
| // var to store the built HTML |
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 characters
| CASE | |
| when Screen Resolution IN ("320x480") THEN "iPhone 1-4" | |
| when Screen Resolution IN ("320x568") THEN "iPhone 5, SE, 5C, 5S" | |
| when Screen Resolution IN ("375x667") THEN "iPhone 6, 6S, 7, 8, SE 2020" | |
| when Screen Resolution IN ("414x736") THEN "iPhone 6+, 6S+, 7+, 8+" | |
| when Screen Resolution IN ("375x812") THEN "iPhone X, XS, 11 Pro" | |
| when Screen Resolution IN ("414x896") THEN "iPhone 11, XR, XS Max, 11 Pro Max" | |
| when Screen Resolution IN ("390x844") THEN "iPhone 12, 12 Pro" | |
| when Screen Resolution IN ("360x780") THEN "iPhone 12 Mini" | |
| when Screen Resolution IN ("428x926") THEN "iPhone 12 Pro Max" |
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 characters
| const site = 'www.bbc.co.uk'; | |
| const subdomain1 = 'm.files.bbci.co.uk'; | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| event.respondWith(handleRequest(request)) | |
| }); | |
| async function handleRequest(request) { | |
| const url = new URL(request.url); |
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 characters
| // what are the domains we are wanting to modify | |
| const site = 'www.bbc.co.uk'; | |
| const subdomain1 = 'm.files.bbci.co.uk'; | |
| // do this on a fetch | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| event.respondWith(handleRequest(request)) | |
| }); |
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 characters
| // set the site we are modifying | |
| const site = 'www.example.com'; | |
| // do this on a fetch | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| const url = new URL(request.url) | |
| event.respondWith(handleRequest(request)) | |
| }); |
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 characters
| // set the site we are modifying | |
| const site = 'www.example.com'; | |
| // do this on a fetch | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| const url = new URL(request.url) | |
| event.respondWith(handleRequest(request)) | |
| }); |
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 characters
| // set the site we are modifying | |
| const site = 'www.example.com'; | |
| // do this on a fetch | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| const url = new URL(request.url) | |
| event.respondWith(handleRequest(request)) | |
| }); |
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 characters
| // set the site we are modifying | |
| const site = 'www.example.com'; | |
| // do this on a fetch | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| const url = new URL(request.url) | |
| event.respondWith(handleRequest(request)) | |
| }); |
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 characters
| // set the site we are modifying | |
| const site = 'www.example.com'; | |
| // do this on a fetch | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| const url = new URL(request.url) | |
| event.respondWith(handleRequest(request)) | |
| }); |
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 characters
| // set the site we are modifying | |
| const site = 'www.example.com'; | |
| // do this on a fetch | |
| addEventListener('fetch', event => { | |
| const request = event.request | |
| const url = new URL(request.url) | |
| event.respondWith(handleRequest(request)) | |
| }); |