Skip to content

Commit 8d67d6c

Browse files
authored
1 parent 994cfc9 commit 8d67d6c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

youtube-thumbnails.html

+21
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ <h1>YouTube Thumbnail Viewer</h1>
101101
this.nextElementSibling.textContent = `Width: ${this.naturalWidth}px`;
102102
}
103103
});
104+
105+
// Update URL
106+
updateURL(input);
104107
}
105108
}
106109

@@ -115,6 +118,24 @@ <h1>YouTube Thumbnail Viewer</h1>
115118
console.error('Failed to copy: ', err);
116119
});
117120
}
121+
122+
function updateURL(input) {
123+
const url = new URL(window.location);
124+
url.searchParams.set('url', input);
125+
window.history.pushState({}, '', url);
126+
}
127+
128+
function loadFromURL() {
129+
const urlParams = new URLSearchParams(window.location.search);
130+
const urlValue = urlParams.get('url');
131+
if (urlValue) {
132+
document.getElementById("videoInput").value = urlValue;
133+
updateThumbnails();
134+
}
135+
}
136+
137+
// Call loadFromURL when the page loads
138+
window.onload = loadFromURL;
118139
</script>
119140

120141
</body>

0 commit comments

Comments
 (0)