chatgpt-4o-latest-20250326· OpenAI
LMArena Human Preference 140K
https://www.photoshelter.com/search/の結果からimage popupを抑制するuserscriptを
- User
https://www.photoshelter.com/search/の結果からimage popupを抑制するuserscriptを
- Assistant
Photoshelterの検索結果ページ(例:
https://www.photoshelter.com/search/)では、検索結果のサムネイルをクリックすると、JavaScriptによって画像ポップアップ(ライトボックス)が表示されることがあります。このポップアップを**表示させないようにするUserScript(ユーザースクリプト)**を書いて、ブラウザ(Tampermonkeyなど)で実行させる方法をご紹介します。
✅ 目的
https://www.photoshelter.com/search/ページで、画像クリック時に表示される 画像ポップアップ (Lightbox モーダル) を無効化または抑制したい。
✅ UserScript サンプルコード
以下のスクリプトをTampermonkeyなどのユーザースクリプトマネージャに追加してください。
// ==UserScript== // @name Photoshelter - Disable Image Popup // @namespace https://www.example.com // @version 1.0 // @description Prevent image popup (lightbox) on Photoshelter search results // @author ChatGPT // @match https://www.photoshelter.com/search/* // @grant none // ==/UserScript== (function () { 'use strict'; // Debug message console.log("Photoshelter Image Popup Suppression Script loaded"); // A function to disable default click behavior on thumbnails function preventLightboxPopup() { // Select all clickable thumbnails or containers const imageLinks = document.querySelectorAll('a.js-gallery-thumb-link'); imageLinks.forEach(link => { // Clone the link to remove all listeners (Photoshelter uses inline event listeners) const newLink = link.cloneNode(true); newLink.addEventListener('click', function (e) { e.stopPropagation(); e.preventDefault(); console.log("Popup suppressed for image:", newLink.href); // OPTIONAL: You can open the link in a new tab if you want: // window.open(newLink.href, '_blank'); }); link.replaceWith(newLink); }); } // Run the function on initial load preventLightboxPopup(); // In case content is injected dynamically, observe DOM changes const observer = new MutationObserver(function (mutations) { preventLightboxPopup(); }); observer.observe(document.body, { childList: true, subtree: true }); })();
✅ 処理の内容
.js-gallery-thumb-link要素(画像サムネイルのリンク)を対象にしています。clickイベントをフックして、オリジナルのポップアップ動作(JavaScriptライトボックス)をpreventDefault()/stopPropagation()で抑制します。- ターゲット要素をクローンして、元のイベントリスナを無効化。
- DOMの変化があっても動作するように、MutationObserver を使用しています。
✅ 使用方法
- Tampermonkeyなどをブラウザにインストール。
- 新しいスクリプトを作成し、上記スクリプトをペースト。
- 保存して有効化。
https://www.photoshelter.com/search/にアクセスすると、クリックしてもポップアップが表示されないように。
✅ オプション(お好みで)
- サムネイルクリック時に別タブで画像リンクを開かせたりすることもできます。コメント内の行を有効にしてください。
// window.open(newLink.href, '_blank');
ご希望があれば、特定の動作(例えば画像URLを新しいタブで開くなど)にカスタマイズも可能です!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.