1;(function(mod){ 2function collectLinks() { 3 return Array.prototype.slice.apply( 4 document.head.querySelectorAll('link[rel*="icon"]') 5 ) 6} 7 8function applyLink(source, target) { 9 target.setAttribute('type', source.getAttribute('type')) 10 target.setAttribute('href', source.getAttribute('href')) 11} 12 13// eslint-disable-next-line no-unused-vars 14function initSwitcher(delay) { 15 // Exit if media queries aren't supported 16 if (typeof window.matchMedia !== 'function') { 17 return function noop() {} 18 } 19 20 var links = collectLinks() 21 var current = document.createElement('link') 22 var prevMatch 23 24 current.setAttribute('rel', 'shortcut icon') 25 document.head.appendChild(current) 26 27 function faviconApplyLoop() { 28 var matched 29 30 links.forEach(function(link) { 31 if (window.matchMedia(link.media).matches) { 32 matched = link 33 } 34 }) 35 36 if (! matched) { 37 return 38 } 39 40 if (matched.media !== prevMatch) { 41 prevMatch = matched.media 42 applyLink(matched, current) 43 } 44 } 45 46 var intervalId = setInterval(faviconApplyLoop, delay || 300) 47 48 function unsubscribe() { 49 clearInterval(intervalId) 50 links.forEach(function(link) { 51 document.head.appendChild(link) 52 }) 53 } 54 55 faviconApplyLoop() 56 links.forEach(function(link) { 57 document.head.removeChild(link) 58 }) 59 60 return unsubscribe 61} 62 63initSwitcher() 64})()
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.