MCPcopy Create free account
hub / github.com/hoothin/UserScripts / isVideoLink

Function isVideoLink

Picviewer CE+/dist.user.js:25873–25885  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

25871 const audioExtensions = new Set(['flac', 'm4a', 'mp3', 'oga', 'ogg', 'opus', 'wav']);
25872
25873 function isVideoLink(url) {
25874 if (url.indexOf('.video') !== -1 || url.indexOf('video:') === 0)
25875 return true;
25876
25877 url = url.replace(/.gif(\?width=\d*&|\?)format=mp4/, '.mp4?').replace(/\/$/, "");
25878 if (url.lastIndexOf('?') > 0)
25879 url = url.substring(0, url.lastIndexOf('?'));
25880 const ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase();
25881
25882 return videoExtensions.has(ext)
25883 || url.indexOf('googlevideo.com/videoplayback') > 0
25884 || url.indexOf('v.redd.it') > 0;
25885 }
25886
25887 function isAudioLink(url) {
25888 if (url.indexOf('.audio') !== -1 || url.indexOf('audio:') === 0)

Callers 1

initFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected