https://www.sportsoho.com/pg/photos/thumbnail/10345234/medium/1724031208.jpgのようなサイトでmediu…
- User
Assistant
Sportsoho Image Enlarger Userscript
以下は、Sportsohoサイトの画像URLをmediumからlargeに変換するユーザースクリプトのデモページです。このページでは実際のスクリプト動作をシミュレートできます。
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Sportsoho Image Enlarger - Userscript Demo</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d); color: #fff; min-height: 100vh; padding: 20px; } .container { max-width: 1200px; margin: 0 auto; padding: 20px; } header { text-align: center; padding: 30px 0; margin-bottom: 40px; background: rgba(0, 0, 0, 0.4); border-radius: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); } h1 { font-size: 2.8rem; margin-bottom: 10px; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); } .subtitle { font-size: 1.4rem; opacity: 0.9; margin-bottom: 20px; } .content { display: flex; flex-wrap: wrap; gap: 30px; margin-bottom: 40px; } .panel { flex: 1; min-width: 300px; background: rgba(20, 20, 30, 0.7); border-radius: 15px; padding: 25px; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4); backdrop-filter: blur(10px); } .panel h2 { color: #fdbb2d; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #fdbb2d; } .image-container { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; margin: 30px 0; } .image-box { width: 100%; max-width: 350px; background: rgba(0, 0, 0, 0.4); border-radius: 10px; overflow: hidden; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); transition: transform 0.3s ease; } .image-box:hover { transform: translateY(-5px); } .image-box img { width: 100%; height: 200px; object-fit: cover; display: block; } .image-info { padding: 15px; } .image-info h3 { font-size: 1.2rem; margin-bottom: 10px; color: #fdbb2d; } .image-info p { font-size: 0.9rem; color: #ddd; margin-bottom: 8px; } .url-display { background: rgba(0, 0, 0, 0.3); padding: 10px; border-radius: 5px; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .instructions { background: rgba(30, 30, 40, 0.8); border-radius: 15px; padding: 25px; margin-top: 30px; box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4); } .instructions h2 { color: #1a9cff; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #1a9cff; } .code-block { background: #1e1e2e; border-radius: 8px; padding: 20px; margin: 20px 0; overflow-x: auto; font-family: 'Courier New', monospace; font-size: 0.95rem; line-height: 1.5; } .btn { display: inline-block; background: linear-gradient(to right, #1a9cff, #0066cc); color: white; padding: 12px 25px; border-radius: 30px; text-decoration: none; font-weight: bold; margin: 10px 5px; transition: all 0.3s ease; border: none; cursor: pointer; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); } .btn:hover { transform: translateY(-3px); box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4); } .btn-orange { background: linear-gradient(to right, #fdbb2d, #ff8c00); } .btn-green { background: linear-gradient(to right, #00c853, #009624); } .highlight { color: #fdbb2d; font-weight: bold; } footer { text-align: center; padding: 30px 0; margin-top: 40px; font-size: 0.9rem; color: #aaa; border-top: 1px solid rgba(255, 255, 255, 0.1); } .dynamic-content { margin-top: 30px; padding: 20px; background: rgba(0, 0, 0, 0.3); border-radius: 10px; } .dynamic-content h3 { margin-bottom: 15px; color: #1a9cff; } @media (max-width: 768px) { .content { flex-direction: column; } h1 { font-size: 2.2rem; } } </style> </head> <body> <div class="container"> <header> <h1>Sportsoho Image Enlarger</h1> <p class="subtitle">Medium サイズの画像を Large サイズに自動変換するユーザースクリプト</p> <div> <button class="btn btn-orange" id="simulate">スクリプト動作をシミュレート</button> <button class="btn btn-green" id="reset">リセット</button> </div> </header> <div class="content"> <div class="panel"> <h2>変換前の画像 (Medium)</h2> <div class="image-container"> <div class="image-box"> <img src="https://www.sportsoho.com/pg/photos/thumbnail/10345234/medium/1724031208.jpg" alt="Sports Image"> <div class="image-info"> <h3>サッカーの試合</h3> <p>サイズ: 400 × 300</p> <div class="url-display">https://www.sportsoho.com/pg/photos/thumbnail/10345234/medium/1724031208.jpg</div> </div> </div> <div class="image-box"> <img src="https://www.sportsoho.com/pg/photos/thumbnail/10345235/medium/1724031209.jpg" alt="Sports Image"> <div class="image-info"> <h3>バスケットボール</h3> <p>サイズ: 400 × 300</p> <div class="url-display">https://www.sportsoho.com/pg/photos/thumbnail/10345235/medium/1724031209.jpg</div> </div> </div> </div> </div> <div class="panel"> <h2>変換後の画像 (Large)</h2> <div class="image-container"> <div class="image-box"> <img src="https://www.sportsoho.com/pg/photos/thumbnail/10345234/large/1724031208.jpg" alt="Sports Image"> <div class="image-info"> <h3>サッカーの試合</h3> <p>サイズ: 800 × 600</p> <div class="url-display">https://www.sportsoho.com/pg/photos/thumbnail/10345234/large/1724031208.jpg</div> </div> </div> <div class="image-box"> <img src="https://www.sportsoho.com/pg/photos/thumbnail/10345235/large/1724031209.jpg" alt="Sports Image"> <div class="image-info"> <h3>バスケットボール</h3> <p>サイズ: 800 × 600</p> <div class="url-display">https://www.sportsoho.com/pg/photos/thumbnail/10345235/large/1724031209.jpg</div> </div> </div> </div> </div> </div> <div class="dynamic-content"> <h3>動的コンテンツシミュレーション</h3> <p>このセクションはユーザースクリプトが動的に追加されるコンテンツを処理できることを示しています。</p> <button class="btn" id="addImage">画像を動的に追加</button> <div id="dynamicImages" style="margin-top: 20px;"></div> </div> <div class="instructions"> <h2>ユーザースクリプトのインストール方法</h2> <p>以下のスクリプトをTampermonkeyまたはViolentmonkeyに追加してください:</p> <div class="code-block"> <pre><code>// ==UserScript== // @name Sportsoho Image Enlarger // @namespace http://tampermonkey.net/ // @version 1.0 // @description sportsoho.comの画像URLをmediumからlargeに変換 // @author YourName // @match *://*.sportsoho.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // URL変換関数 function convertToLarge(url) { return url.replace(/\/medium\//g, '/large/'); } // 要素の処理 function processElements(elements, attribute) { elements.forEach(el => { const url = el.getAttribute(attribute); if (url && url.includes('/medium/')) { const newUrl = convertToLarge(url); el.setAttribute(attribute, newUrl); } }); } // メイン処理関数 function processPage() { // img要素の処理 const images = Array.from(document.querySelectorAll('img')); processElements(images, 'src'); // a要素の処理 const links = Array.from(document.querySelectorAll('a')); processElements(links, 'href'); } // MutationObserverで動的コンテンツを監視 const observer = new MutationObserver(mutations => { mutations.forEach(() => { processPage(); }); }); // オブザーバーの設定 observer.observe(document.body, { childList: true, subtree: true }); // 初期処理 processPage(); })();</code></pre> </div> <p><span class="highlight">機能説明:</span></p> <ul> <li>Sportsohoサイトの画像URLパターンを検出し、mediumをlargeに置換</li> <li>通常のimgタグだけでなく、リンク(aタグ)も処理対象</li> <li>MutationObserverを使用して動的に追加されるコンテンツにも対応</li> <li>元のURLに/medium/が含まれている場合のみ処理</li> </ul> <p><span class="highlight">注意:</span> このスクリプトはsportsoho.comドメインでのみ動作します</p> </div> <footer> <p>Sportsoho Image Enlarger Userscript Demo © 2023</p> </footer> </div> <script> // シミュレーションスクリプト document.getElementById('simulate').addEventListener('click', function() { // 画像の変換 const images = document.querySelectorAll('.panel:first-child .image-box img'); images.forEach(img => { img.src = img.src.replace('/medium/', '/large/'); }); // URL表示の更新 const urlDisplays = document.querySelectorAll('.panel:first-child .url-display'); urlDisplays.forEach(display => { display.textContent = display.textContent.replace('/medium/', '/large/'); }); // 情報テキストの更新 const infoTexts = document.querySelectorAll('.panel:first-child .image-info p'); infoTexts.forEach(text => { if (text.textContent.includes('400 × 300')) { text.textContent = 'サイズ: 800 × 600'; } }); alert('画像をmediumからlargeに変換しました!'); }); // リセット機能 document.getElementById('reset').addEventListener('click', function() { // 画像を元に戻す const images = document.querySelectorAll('.panel:first-child .image-box img'); images[0].src = 'https://www.sportsoho.com/pg/photos/thumbnail/10345234/medium/1724031208.jpg'; images[1].src = 'https://www.sportsoho.com/pg/photos/thumbnail/10345235/medium/1724031209.jpg'; // URL表示を元に戻す const urlDisplays = document.querySelectorAll('.panel:first-child .url-display'); urlDisplays[0].textContent = 'https://www.sportsoho.com/pg/photos/thumbnail/10345234/medium/1724031208.jpg'; urlDisplays[1].textContent = 'https://www.sportsoho.com/pg/photos/thumbnail/10345235/medium/1724031209.jpg'; // 情報テキストを元に戻す const infoTexts = document.querySelectorAll('.panel:first-child .image-info p'); infoTexts.forEach(text => { if (text.textContent.includes('800 × 600')) { text.textContent = 'サイズ: 400 × 300'; } }); // 動的に追加された画像を削除 document.getElementById('dynamicImages').innerHTML = ''; alert('ページをリセットしました!'); }); // 動的画像追加機能 document.getElementById('addImage').addEventListener('click', function() { const dynamicContainer = document.getElementById('dynamicImages'); const newImage = document.createElement('div'); newImage.className = 'image-box'; newImage.innerHTML = ` <img src="https://www.sportsoho.com/pg/photos/thumbnail/10345236/medium/1724031210.jpg" alt="Dynamic Image"> <div class="image-info"> <h3>動的に追加された画像</h3> <p>サイズ: 400 × 300</p> <div class="url-display">https://www.sportsoho.com/pg/photos/thumbnail/10345236/medium/1724031210.jpg</div> </div> `; dynamicContainer.appendChild(newImage); // シミュレートボタンが押されている場合はlargeに変換 if (document.querySelector('.panel:first-child .image-box img').src.includes('large')) { const img = newImage.querySelector('img'); img.src = img.src.replace('/medium/', '/large/'); const display = newImage.querySelector('.url-display'); display.textContent = display.textContent.replace('/medium/', '/large/'); const sizeText = newImage.querySelector('.image-info p'); sizeText.textContent = 'サイズ: 800 × 600'; } }); </script> </body> </html>機能説明
このデモページでは、Sportsoho Image Enlargerユーザースクリプトの動作をシミュレートできます:
-
スクリプト動作シミュレーション:
- 「スクリプト動作をシミュレート」ボタンをクリックすると、mediumサイズの画像URLをlargeサイズに変換
- 画像サイズ表示とURL表示も更新されます
-
動的コンテンツ対応:
- 「画像を動的に追加」ボタンで新しい画像を追加
- スクリプトが有効な状態では、動的に追加された画像も自動的に変換されます
-
リセット機能:
- 「リセット」ボタンでページを元の状態に戻せます
-
実際のユーザースクリプトコード:
- ページ下部に実際に使用できるユーザースクリプトの完全なコードを表示
- MutationObserverを使用して動的コンテンツにも対応
- imgタグとaタグの両方を処理
このユーザースクリプトをインストールすると、Sportsohoサイトの画像が自動的に高解像度版に変換され、より鮮明な画像を閲覧できるようになります。
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.