1(function () { 2 document.addEventListener('DOMContentLoaded', function () { 3 var meta = document.querySelector('meta[name="pagesicon-favicon"]'); 4 if (!meta) return; 5 6 var href = meta.getAttribute('content'); 7 if (!href) return; 8 9 var links = document.head.querySelectorAll('link[rel*="icon"]'); 10 for (var i = 0; i < links.length; i++) { 11 if (links[i].parentNode) { 12 links[i].parentNode.removeChild(links[i]); 13 } 14 } 15 16 var icon = document.createElement('link'); 17 icon.rel = 'icon'; 18 icon.href = href; 19 document.head.appendChild(icon); 20 21 var shortcut = document.createElement('link'); 22 shortcut.rel = 'shortcut icon'; 23 shortcut.href = href; 24 document.head.appendChild(shortcut); 25 }); 26})(); 27