Skip to content

Instantly share code, notes, and snippets.

@oflow
Created April 25, 2016 02:12
Show Gist options
  • Save oflow/9ea9ee696c94a38ce1191317767ed5d5 to your computer and use it in GitHub Desktop.
Save oflow/9ea9ee696c94a38ce1191317767ed5d5 to your computer and use it in GitHub Desktop.
右クリックメニューから画像検索
<?xml version="1.0" encoding="UTF-8"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--
// ==UserScript==
// @name Context Google Image Search
// @description 右クリックメニューから画像検索
// @version 1.0
// @include main
// @compatibility Firefox 45
// @author oflow
// @namespace https://oflow.me/
// ==/UserScript==
-->
<script type="application/x-javascript"><![CDATA[
var ucjsContextGoogleImage = {
init: function() {
document.getElementById('contentAreaContextMenu').addEventListener('popupshowing', this, false);
window.addEventListener('unload', this, false);
},
handleEvent: function(event) {
switch (event.type) {
case 'popupshowing':
document.getElementById('context-google-image-search').hidden = !gContextMenu.mediaURL;
break;
case 'unload':
document.getElementById('contentAreaContextMenu').removeEventListener('popupshowing', this, false);
window.removeEventListener('unload', this, false);
}
},
search: function() {
if (!gContextMenu.mediaURL) return;
gBrowser.addTab('https://www.google.co.jp/searchbyimage?image_url=' + encodeURIComponent(gContextMenu.mediaURL));
}
}
ucjsContextGoogleImage.init();
]]></script>
<menupopup id="contentAreaContextMenu">
<menuitem id="context-google-image-search"
label="画像を Google で検索"
accesskey="S"
oncommand="ucjsContextGoogleImage.search()"
hidden="true"
insertafter="context-copyimage" />
</menupopup>
</overlay>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment