1(function() { 2 'use strict'; 3 4 function isExportView() { 5 return document.body.classList.contains('is-export') || 6 window.location.pathname.indexOf('/inline/') !== -1 || 7 window.location.pathname.indexOf('/pdfs/') !== -1; 8 } 9 10 function addBrandIconAndWrapText(link, iconFile) { 11 if (link.querySelector('.article-link-brand-icon')) return; 12 13 var existingStats = link.querySelector('.project-live-stats'); 14 if (existingStats) { 15 existingStats.remove(); 16 } 17 18 var innerSvgs = link.querySelectorAll('svg, .render-svg-icon, .skill-icon-svg'); 19 innerSvgs.forEach(function(s) { 20 s.remove(); 21 }); 22 23 var originalHtml = link.innerHTML.trim(); 24 var tempDiv = document.createElement('div'); 25 tempDiv.innerHTML = originalHtml; 26 if (tempDiv.children.length === 1 && tempDiv.firstElementChild.tagName === 'SPAN') { 27 originalHtml = tempDiv.firstElementChild.innerHTML.trim(); 28 } 29 var headerHtml = '<span class="article-link-header"><span class="article-link-brand-icon" style="-webkit-mask-image: url(\'/icons/' + iconFile + '\'); mask-image: url(\'/icons/' + iconFile + '\');"></span><span class="article-link-text">' + originalHtml + '</span></span>'; 30 link.innerHTML = headerHtml; 31 32 if (existingStats) { 33 link.appendChild(existingStats); 34 } 35 } 36 37 function initArticleWidgets() { 38 if (isExportView()) return; 39 40 var articleLinks = document.querySelectorAll('.post-body-markdown a, .project-card a, .window-footer a, .window-body a'); 41 articleLinks.forEach(function(link) { 42 if (link.closest('.chain-export-buttons') || link.classList.contains('rss-link-btn')) return; 43 if (link.classList.contains('accolade-link-btn') || 44 link.classList.contains('fav-detail-btn') || 45 link.classList.contains('fav-filter-btn') || 46 link.classList.contains('export-btn-sm-clean') || 47 link.closest('.game-jam-box') || 48 link.closest('.game-landing-container') || 49 link.closest('.fav-card') || 50 link.closest('.fav-card-collection') || 51 link.closest('.imdb-widget-container') || 52 link.closest('.fav-player-section')) return; 53 54 var href = link.getAttribute('href'); 55 if (!href) return; 56 57 // 1. Gist Link (must be checked BEFORE repo link) 58 var gistMatch = href.match(/^https?:\/\/gist\.github\.com\/(?:[a-zA-Z0-9_-]+\/)?([a-fA-F0-9]+)/); 59 if (gistMatch) { 60 link.classList.add('article-widget-link', 'widget-gist'); 61 link.setAttribute('data-gist-id', gistMatch[1]); 62 addBrandIconAndWrapText(link, 'file-code.svg'); 63 if (window.GistWidget && typeof window.GistWidget.initElement === 'function') { 64 window.GistWidget.initElement(link); 65 } 66 return; 67 } 68 69 // 2. GitHub Repo Link 70 var ghMatch = href.match(/^https?:\/\/github\.com\/([a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+)/); 71 if (ghMatch && !href.includes('github.com/features')) { 72 link.classList.add('article-widget-link', 'widget-github'); 73 link.setAttribute('data-github-repo', ghMatch[1]); 74 addBrandIconAndWrapText(link, 'github.svg'); 75 if (window.GithubWidget && typeof window.GithubWidget.initElement === 'function') { 76 window.GithubWidget.initElement(link); 77 } 78 return; 79 } 80 81 // 3. IMDb Link (skip for whoami profile contact links) 82 var imdbMatch = href.match(/^https?:\/\/(?:www\.)?imdb\.com\/(?:title|name)\/([a-zA-Z0-9]+)/); 83 if (imdbMatch && !link.classList.contains('whoami-link') && !link.closest('.whoami-grid, .whoami-card, .whoami-profile-header')) { 84 link.classList.add('article-widget-link', 'widget-imdb'); 85 link.setAttribute('data-imdb-id', imdbMatch[1]); 86 addBrandIconAndWrapText(link, 'imdb.svg'); 87 if (window.ImdbWidget && typeof window.ImdbWidget.initElement === 'function') { 88 window.ImdbWidget.initElement(link); 89 } 90 return; 91 } 92 93 // 4. Itch Link 94 var itchMatch = href.match(/^https?:\/\/([a-zA-Z0-9_-]+)\.itch\.io\/([a-zA-Z0-9_-]+)/); 95 if (itchMatch && itchMatch[1] !== 'www') { 96 link.classList.add('article-widget-link', 'widget-itch'); 97 link.setAttribute('data-itch-user', itchMatch[1]); 98 link.setAttribute('data-itch-game', itchMatch[2]);
99 addBrandIconAndWrapText(link, 'itch-io.svg'); 100 if (window.ItchWidget && typeof window.ItchWidget.initElement === 'function') { 101 window.ItchWidget.initElement(link); 102 } 103 return; 104 } 105 106 // 4b. Itch Jam Link 107 var itchJamMatch = href.match(/^https?:\/\/itch\.io\/jam\/([a-zA-Z0-9_-]+)/); 108 if (itchJamMatch) { 109 link.classList.add('article-widget-link', 'widget-itch-jam'); 110 link.setAttribute('data-itch-jam', itchJamMatch[1]); 111 addBrandIconAndWrapText(link, 'trophy.svg'); 112 if (window.ItchJamWidget && typeof window.ItchJamWidget.initElement === 'function') { 113 window.ItchJamWidget.initElement(link); 114 } 115 return; 116 } 117 118 // 5. Steam Link 119 var steamMatch = href.match(/^https?:\/\/store\.steampowered\.com\/app\/(\d+)/); 120 if (steamMatch) { 121 link.classList.add('article-widget-link', 'widget-steam'); 122 link.setAttribute('data-steam-appid', steamMatch[1]); 123 addBrandIconAndWrapText(link, 'steam-symbol.svg'); 124 if (window.SteamWidget && typeof window.SteamWidget.initElement === 'function') { 125 window.SteamWidget.initElement(link); 126 } 127 return; 128 } 129 }); 130 } 131 132 function initLiveStats() { 133 if (isExportView()) return; 134 135 if (window.GithubWidget && typeof window.GithubWidget.init === 'function') { 136 window.GithubWidget.init(); 137 } 138 if (window.GistWidget && typeof window.GistWidget.init === 'function') { 139 window.GistWidget.init(); 140 } 141 if (window.ItchWidget && typeof window.ItchWidget.init === 'function') { 142 window.ItchWidget.init(); 143 } 144 if (window.ItchJamWidget && typeof window.ItchJamWidget.init === 'function') { 145 window.ItchJamWidget.init(); 146 } 147 if (window.SteamWidget && typeof window.SteamWidget.init === 'function') { 148 window.SteamWidget.init(); 149 } 150 if (window.ImdbWidget && typeof window.ImdbWidget.init === 'function') { 151 window.ImdbWidget.init(); 152 } 153 initArticleWidgets(); 154 } 155 156 if (document.readyState === 'loading') { 157 document.addEventListener('DOMContentLoaded', initLiveStats); 158 } else { 159 initLiveStats(); 160 } 161 162 var resizeTimeout; 163 window.addEventListener('resize', function() { 164 clearTimeout(resizeTimeout); 165 resizeTimeout = setTimeout(function() { 166 if (document.querySelector('.whoami-widget-container')) { 167 initLiveStats(); 168 } 169 }, 150); 170 }); 171})();
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.