Skip to content

Instantly share code, notes, and snippets.

@gingerbeardman
Created April 1, 2025 12:43
Show Gist options
  • Save gingerbeardman/47bfd8f6b76a7f33a6262b7998994416 to your computer and use it in GitHub Desktop.
Save gingerbeardman/47bfd8f6b76a7f33a6262b7998994416 to your computer and use it in GitHub Desktop.
Automatically redirects to download page and clicks the download button, for temporary use
// Redirect to file download at Vector.co.jp
if (window.location.host === 'www.vector.co.jp' && window.location.pathname.startsWith('/soft/')) {
// Extract file ID by removing non-numeric characters
const fileId = window.location.href.replace(/\D/g, '');
// Construct new URL with file ID
window.location.href = `https://www.vector.co.jp/download/file/mac/game/fh${fileId}.html`;
}
// Auto-click the first link in #summary section on Vector.co.jp download pages
(function() {
// Check URL pattern
if (window.location.host === 'www.vector.co.jp' &&
window.location.pathname.startsWith('/download/file/mac/game/') &&
window.location.pathname.match(/fh\d+\.html$/)) {
function clickSummaryLink() {
try {
// Method 1: Direct querySelector
const summaryLink = document.querySelector('#summary a');
if (summaryLink) {
summaryLink.click();
return true;
}
// Fallback: Log if no link found
console.log('No suitable link found to click');
return false;
} catch (error) {
console.error('Error clicking link:', error);
return false;
}
}
// Try multiple methods to ensure link is clicked
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', clickSummaryLink);
} else {
clickSummaryLink();
}
// Backup: Try again after a short delay
// setTimeout(clickSummaryLink, 1000);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment