var addCopyMetadata = function() { if (!copyMetadata) { copyMetadata = contextMenu.Item({ label: 'Copy image metadata', data: 'image', context: [ contextMenu.SelectorContext('img[' + attr.metadata + '], [' + attr.overlayId + ']') ], contentScriptFile: [ data.url('data_attr.js'), data.url('menu_item_copy_rdfxml.js')], onMessage: function(msg) { var window = winUtils.getFocusedWindow(); if (window === null) { console.log("can't find focused window"); return false; } copymeta.copyRDFXML(window, msg.rdf); } }); } if (!copyPageMetadata) { copyPageMetadata = contextMenu.Item({ label: 'Copy page metadata', data: 'page', context: [ contextMenu.PageContext(), contextMenu.SelectorContext('body[' + attr.metadata + ']') ], contentScriptFile: [ data.url('data_attr.js'), data.url('menu_item_copy_rdfxml.js')], onMessage: function(msg) { var window = winUtils.getFocusedWindow(); if (window === null) { console.log("can't find focused window"); return false; } copymeta.copyRDFXML(window, msg.rdf); } }); } };
function setLinkCm () { var obj = { localeObject: { emptyString: _("emptyString"), notPresent: _("notPresent") }, showAltText: prefs.showAltText, highlightColor: prefs.highlightColor, highlightBackgroundColor: prefs.highlightBackgroundColor, highlightingEnabled: prefs.highlightingEnabled }; linkCm = cm.Item({ label: _("copylinktextContext.label"), accesskey: prefs.copyLinkTextAccessKey || _("copylinktextContext.accesskey"), context: cm.SelectorContext('a[href]'), contentScriptFile: data.url('link-context-menu.js'), data: JSON.stringify(obj), onMessage: function (arr) { var alts = arr[1], copytext = alts ? _("addAltToLinkText", arr[0], alts.join(_("altJoin"))) : arr[0]; return copyToClipboard(copytext); } }); }
exports.menu = function (label, ...items) { let selector = 'a[href], video, audio, img'; if (desktop) { let contextMenu = require('sdk/context-menu'); contextMenu.Menu({ label, image: data.url('./icons/32.png'), context: contextMenu.SelectorContext(selector), items: items.map(arr => contextMenu.Item({ label: arr[0], contentScriptFile: data.url('./firefox/menu.js'), onMessage: node => arr[1](node) })) }); } else { let window = Services.wm.getMostRecentWindow('navigator:browser'); let id = window.NativeWindow.contextmenus.add( 'Download With Turbo Download Manager', window.NativeWindow.contextmenus.SelectorContext(selector), (target) => items[0][1](require('../../data/firefox/menu.js').click(target)) ); unload.when(() => window.NativeWindow.contextmenus.remove(id)); } };
function setupContextMenus() { if (sendUri == null) { sendUri = contextMenu.Item({ label: "Send this link to device...", context: contextMenu.SelectorContext("a[href]"), contentScript: 'self.on("click", function(node) {' + ' let title = document.title;' + ' let uri = node.href;' + ' self.postMessage([uri, title]);' + '});', onMessage: function onMessage(data) { promptAndSendURIToDevice(data[0], data[1]); } }); } if (sendPage == null) { sendPage = contextMenu.Item({ label: "Send this page to device...", context: contextMenu.PageContext(), contentScript: 'self.on("click", function(node) {' + ' let title = document.title;' + ' let uri = document.URL;' + ' self.postMessage([uri, title]);' + '});', onMessage: function onMessage(data) { promptAndSendURIToDevice(data[0], data[1]); } }); } }
var run = function () { if (running) { return; } running = true; etherpad.loadPlaceholders(); tabs.on('open', tabOpen); tabOpen(); menuitem = cm.Item({ label: 'Copy Thumbnail URL', context: [ cm.URLContext('about:newtab'), cm.SelectorContext('.newtab-thumbnail') ], contentScript: 'self.on("click", function(node, data) {' + ' self.postMessage(node.getAttribute("data-thumburl"));' + '});', onMessage: function (thumbUrl) { clipboard.set(thumbUrl); } }); menuitem.image = null; };
/** * Set up form context menu (may be destroyed if option disabled) */ function setFormCm () { /* // Since there is no apparent way to pass parameters to the context menu, we create new ones var contentScript = ['accessFormControls', 'accessPass', 'immediateFormClickExecution'].reduceRight(function (prev, next) { return (prefs[next] ? next + '-' : '') + prev; }, 'form-cm.js'); contentScript = 'form-context-menu.js'; */ if (!prefs.accessFormControls) { return; } var immediateFormClickExecution = prefs.immediateFormClickExecution, obj = { localeObject: { joinOptsText: _("joinOptsText"), joinOpts: _("joinOpts") } }, sel = 'input[type]:not([type=text])' + (prefs.accessPass ? '' : ':not([type=password])') + ', select, button, img'; if (immediateFormClickExecution) { formMod = pageMod.PageMod({ include: ['*', 'file://*'], contentScriptWhen: 'ready', attachTo: ['top', 'frame', 'existing'], contentScriptOptions: {sel: sel, localeObject: obj.localeObject}, contentScriptFile: [data.url('mouseDown.js'), data.url('form-pagemod-script.js')], onAttach: function (worker) { worker.port.on('mouseDown', function (val) { copyToClipboard(val); }); } }); } formCm = cm.Item({ label: _("copyformtextContext.label"), accesskey: _("copyformtextContext.accesskey"), // Useful for type=password, // (checkbox, radio), // (button, submit, reset), // file, image (doesn't work with initial setting of value) // (not getting hidden) context: cm.SelectorContext(sel), contentScriptFile: [data.url('mouseDown.js'), data.url('form-context-menu.js')], data: JSON.stringify(obj), onMessage: function (arr) { copyToClipboard(getCopyTextFromPrompt.apply(null, arr)); } }); }
function addContextMenuItem() { //Adding context menu item cm.Item({ label: "PlayIt on XBMC", context: cm.SelectorContext("a[href]"), contentScript: 'self.on("click", function (node, data) {' + ' self.postMessage([node.href,node.textContent.trim()]);' + '});', onMessage: function (hyperlink) { myAlert("Video selected", hyperlink[1]); playIt(prefs.serviceAddress,prefs.servicePort,hyperlink[0]); } }); }
(function() { var data = require("sdk/self").data; var contextMenu = require("sdk/context-menu"); var tabs = require("sdk/tabs"); var menuItem = contextMenu.Item({ label: "Download from Instagram", context: [ contextMenu.SelectorContext(".photoShadow, .compPhotoShadow"), // contextMenu.SelectorContext(".Image.iLoaded"), contextMenu.URLContext("*.instagram.com") ], contentScriptFile: data.url("downloader-script.js"), onMessage: function (instaUrl) { tabs.open(instaUrl); } }); }());
var addMenuItem = function () { if (!menuitem) { menuitem = cm.Item({ label: 'Copy Thumbnail URL', context: [ cm.URLContext('about:newtab'), cm.SelectorContext('.newtab-cell') ], contentScript: 'self.on("click", function(node, data) {' + ' self.postMessage(node.dataset.thumburl);' + '});', onMessage: function (thumbUrl) { clipboard.set(thumbUrl); } }); menuitem.image = null; } };
create: function(chemObjModifyPanel) { // modify molecule item return cm.Item({ label: globalConsts.CAPTION_MENU_MODIFY_CHEMOBJ, //"Modify molecule...", data: globalConsts.MENU_MODIFY_CHEMOBJ, context: cm.SelectorContext(WIDGET_SELECTOR), contentScriptFile: [ self.data.url('../lib/globalConsts.js'), self.data.url('../lib/globalUtils.js'), self.data.url('./components/chemObjModifyContextMenu.js') ], onMessage: function (msg) { if (msg.message = globalConsts.MSG_SHOW) chemObjModifyPanel.show({'querySelElem': true}); } }); }
exports.main = function() { cm.Item({ // Already accessible on "View image info"->Associated text, but we'll allow more direct access label: _("copyalttextContext.label"), accesskey: _("copyalttextContext.accesskey"), context: cm.SelectorContext('img'), contentScriptFile: data.url('alt-context-menu.js'), onMessage: function (txt) { copyToClipboard(txt); } }); simplePrefs.on('', setByPref); setByPref('showAltText'); // setByPref('copyLinkTextAccessKey'); // Handled by the line above setByPref('accessFormControls'); // These two handled by the line above // setByPref('accessPass'); // setByPref('immediateFormClickExecution'); };
var addMenuItem = function () { if (!menuitem) { menuitem = cm.Item({ label: 'Copy Thumbnail URL', context: [ cm.URLContext('about:newtab'), cm.SelectorContext('.newtab-cell') ], contentScript: 'self.on("click", function(node, data) {\n' + ' let thumbs = node.getElementsByClassName("newtab-thumbnail");\n' + ' if (thumbs.length) {\n' + ' node = thumbs[0];\n' + ' }\n' + ' self.postMessage("" + node.dataset.thumburl);\n' + '});\n', onMessage: function (thumbUrl) { clipboard.set(thumbUrl); } }); menuitem.image = null; } };
//Set up the top context menu with submenus function setUpTopMenu(mitems) { playon = cm.Menu({ label: "Play on", image: data.url('play.png'), contentScript: 'self.on("click", function (node, data) {' + ' self.postMessage({url:node.href,pathname:node.pathname,server:data,type:node.nodeName,src:node.currentSrc});' + '});', items: mitems[0], onMessage: function (data) { if(data.type==='A'){ //Link parseUrlPlay(data.url, data.pathname, data.server); }else{ //Video parseUrlPlay(data.src, '', data.server); } } }); /* queueon = cm.Menu({ label: "Queue on", image: data.url('queue.png'), contentScript: 'self.on("click", function (node, data) {' + ' self.postMessage({url:node.href,pathname:node.pathname,server:data});' + '});', items: mitems[1], onMessage: function (data) { parseUrlQueue(data.url, data.pathname, data.server); } }); */ topmenu = cm.Menu({ label: "Send to Kodi", context: cm.SelectorContext('a,video,audio'), image: data.url('kodi-icon.ico'), contentScriptFile: data.url("rightclickparser.js"), items: [playon, /*queueon,*/ separator, manager] }); }
function init(pnl) { cmenu.Item({ label: _("cmenuShareImage"), image: IMAGE, data: "image", context: cmenu.SelectorContext("img"), contentScriptFile: SCRIPT, onMessage: function(d) { showPanel(pnl, d); } }); cmenu.Item({ label: _("cmenuShareVideo"), image: IMAGE, data: "video", context: [cmenu.PageContext(), cmenu.URLContext(/^\b(https?):\/\/www\.youtube\.com\/watch\?.*/) ], contentScriptFile: SCRIPT, onMessage: function(d) { showPanel(pnl, d); } }); cmenu.Item({ label: _("cmenuShareSelection"), image: IMAGE, data: "selection", context: cmenu.SelectionContext(), contentScriptFile: SCRIPT, onMessage: function(d) { showPanel(pnl, d); } }); }
simplePrefs.on("showVideoInsteadOfGif", () => { redirecter.enable(simplePrefs.prefs.showVideoInsteadOfGif); }); simplePrefs.on("resImageViewerSupport", () => { let enable = simplePrefs.prefs.resImageViewerSupport; pageMod.enable(enable); redirecter.enable(enable); }); // ------------------------------------------------------------------------------ // Setup context menu items // ------------------------------------------------------------------------------ contextMenu.Item({ label: "View as HTML5 Video", data: "gccfx-viewAsHtml5Video", context: contextMenu.SelectorContext("img[src*=\".gif\"]"), contentScriptFile: self.data.url("contextMenuClick.js"), image: self.data.url("images/icon-16.png"), onMessage: function (src) { tabs.open(properties.addon.chromePageUrl + src); } }); // ------------------------------------------------------------------------------ // Initialize // ------------------------------------------------------------------------------ redirecter.enable(simplePrefs.prefs.showVideoInsteadOfGif); pageMod.enable(simplePrefs.prefs.resImageViewerSupport);
} else { args.push("--ytdl-raw-options=yes-playlist=,playlist-start=" + qs["index"]); }; }; }; }; args.push(url); // process.run(false, args, args.length); process.runAsync(args, args.length); } var menuItem = contextMenu.Item({ label: "Watch with MPV", context: contextMenu.SelectorContext("[href]"), contentScript: 'self.on("click", function(node,data){self.postMessage(node.href);})', accessKey: "e", image: data.url("icon_button.png"), onMessage: function (url) { play_video(url); } }); var action_button = ui.ActionButton({ id: "my-button", label: "Play with MPV", icon: data.url("icon_button.png"), onClick: function(state) { play_video(tabs.activeTab.url); }
service = chrome.Cc['@mozilla.org/network/io-service;1']. getService(chrome.Ci.nsIIOService); uri = 'x-choosy://' + method + '/' + escape(url); return service.newURI(uri, null, null); } }; buttons.ActionButton({ 'id': 'choosy', 'label': 'Open with Choosy', 'icon': { '16': './icon16.png', '32': './icon32.png', '64': './icon64.png' }, onClick: function (state) { Choosy.promptAll(tabs.activeTab.url); } }); contextMenu.Item({ 'label': 'Open Link with Choosy', 'context': contextMenu.SelectorContext('a[href]'), 'image': self.data.url('icon32.png'), 'contentScript': 'self.on("click", function (el) { self.postMessage(el.href); });', 'onMessage': function (url) { Choosy.promptAll(url); } });
text_entry.port.emit("show",ss.storage.value,ss.storage.toogle); }); // Listen for messages called "text-entered" coming from // the content script. The message payload is the text the user // entered. // In this implementation we'll just log the text to the console. text_entry.port.on("text-entered", function (text) { text_entry.hide(); }); // Nambah kontext Menu var cm = require("sdk/context-menu"); cm.Item({ label: "Add to WWF Add Block", context: cm.SelectorContext("a[href]"), contentScript: 'self.on("click", function (node, data) {' + ' self.postMessage(node.href);' + '});', onMessage: function (node) { if(ss.storage.value.indexOf(node.split("/",3)[2]) == -1){ ss.storage.value.push(node.split("/",3)[2]); console.log("Tambah : "+node.split("/",3)[2]); }else{ console.log("data sudah tersimpan"); } } }); text_entry.port.on("add-adv", function (node) { if(ss.storage.value.indexOf(node) == -1){ if(node.length > 0){
'use strict'; const tabs = require('sdk/tabs'); const cm = require("sdk/context-menu"); const { URL } = require('sdk/url') const { addScriptlet } = require("./manager"); cm.Item({ label: "Make Scriptlet", context: cm.SelectorContext("a"), contentScript: 'self.on("context", function (node) {' + ' return /^javascript:/.test(node.getAttribute("href"));' + '});' + 'self.on("click", function (node, data) {' + ' var imgs = document.querySelectorAll("img");' + ' var imgSrcs = [];' + ' for (var i = 0 ; i < imgs.length; i++)' + ' imgSrcs.push(imgs[i].src);' + ' self.postMessage({'+ 'href: node.getAttribute("href"),'+ 'title: node.getAttribute("title"),'+ 'textContent: node.textContent'+ '});' + '});', onMessage: function (details) { let downloadURL = URL(tabs.activeTab.url); details.title = details.title || details.textContent.substring(0, 250); details.iconURL = tabs.activeTab.favicon; details.creator = downloadURL.host; details.homepageURL = downloadURL.toString();
if (img === null) { notifications.notify({ title: self.name, text: 'Could not find the image element that should be copied' }); console.warn("onCopyImageMessage: can't find image element: " + msg.id); return false; } copymeta.copyImage(window, img, msg.rdf, msg.subject); }; contextMenu.Item({ label: 'Copy image with credits', context: contextMenu.SelectorContext('img[' + attr.metadata + '], [' + attr.overlayId + ']'), contentScriptFile: [ data.url('libs/uuid.js'), data.url('data_attr.js'), data.url('copy_image.js'), data.url('menu_item_copy_image.js')], onMessage: onCopyImageMessage }); contextMenu.Item({ label: 'Copy main image with credits', context: contextMenu.PageContext(),
ss.storage.blockIlbe = false; return; } if (blockIlbe) { worker.port.emit('block'); } }, contentScriptWhen: "end" }); var addToJjals = cm.Item({ context: cm.SelectorContext("img"), label: "자주쓰는짤에 추가", contentScript: 'self.on("click", function(node) {' + ' self.postMessage(node.src);' + ' alert("추가 되었습니다.");' + '});', onMessage: function (src) { var jjals = ss.storage.jjals; if (ss.storage.jjals == undefined) { jjals = resetJjals(); } jjals.unshift(src); ss.storage.jjals = jjals;
// Closes the panel and takes the button // off the true state function closePanel() { // Close button button.state("window", { checked: false }); } // Context Menu // Right-click -> "Open with Livestreamer" if (prefs.togglecontextmenu) { contextMenu.Item({ label: locale("label"), image: self.data.url(iconPath), context: contextMenu.SelectorContext("a[href], body"), contentScript: 'self.on("click", function(node, data) {' + ' var stream = node.href;' + ' if(!node.href) {' + ' stream = window.location.href;' + ' }' + ' self.postMessage(stream);' + '});', onMessage: function(streamURL) { // Display quality menu? if (prefs.qualityselector) { getLivestreamerValidation(streamURL); } else { runLivestreamer(buildArgs(streamURL)); } panel.show({
var contextmenuitemSelection=cm.Item({ label: _("checkSelectionWithLTShort"), context: cm.SelectionContext(), // SDK bug 851647 contentScript: 'self.on("click", function(){self.postMessage()});', onMessage: function() { showResultsInPanel=(simpleprefs.prefs.contextmenuitemSelectionAction=="popup"); widgetClicked(); }, image: self.data.url("iconSmall.ico") }); var contextmenuitemTextarea=cm.Item({ label: _("checkTextareaWithLTShort"), context: cm.SelectorContext("input, textarea, [contenteditable='true']"), // SDK bug 851647 contentScript: 'self.on("click", function(){self.postMessage()});', onMessage: function() { showResultsInPanel=(simpleprefs.prefs.contextmenuitemTextarea=="popup"); widgetOnClick(); }, image: self.data.url("iconSmall.ico") }); var checkSelectionHotkey=hotkeys.Hotkey({ // combo: "accel-shift-l", combo: simpleprefs.prefs.hotkeySelection, onPress: function() { showResultsInPanel=(simpleprefs.prefs.hotkeySelectionAction=="popup"); widgetClicked();
(function () { var self = require('sdk/self'), data = self.data // Create the wallet panel var walletPanel = require('sdk/panel').Panel({ width:362, height:278, contentURL: data.url('index.html'), onShow: function () { walletPanel.port.emit('show'); walletPanel.port.emit('version', self.version); } }); addListeners(walletPanel); walletPanel.port.on('resize', function (height) { walletPanel.resize(walletPanel.width, height); }); // Attach the wallet to the bitcoin button require('sdk/widget').Widget({ id: 'open-aurora-wallet-btn', label: 'Auroracoin Wallet', contentURL: data.url('auroracoin38.png'), panel: auroraWalletPanel }); // Inject the hover popup scripts into every page /*require('sdk/page-mod').PageMod({ include: '*', contentScriptFile: [ data.url('js/libs/promise.min.js'), data.url('js/libs/jquery.min.js'), data.url('js/libs/bitcoinjs-lib.min.js'), data.url('js/util.js'), data.url('js/preferences.js'), data.url('js/currency-manager.js'), data.url('js/hoverpopup.js')], onAttach: function (worker) { addListeners(worker); } }); */ var tabs = require('sdk/tabs'); // Add listeners to the worker to communicate with scripts function addListeners(worker) { // Get prefs from storage worker.port.on('get', function () { var storage = require('sdk/simple-storage').storage; worker.port.emit('get', storage); }); // Save prefs to storage worker.port.on('save', function (object) { var storage = require('sdk/simple-storage').storage; for (var i in object) { storage[i] = object[i]; } worker.port.emit('save', storage); }); // Open tabs worker.port.on('openTab', function (url) { tabs.open(url); }); // Get HTML for local files worker.port.on('html', function (url) { let content = data.load(url); // Replace relative paths of css files to absolute path content = content.replace(/css\//g, data.url('css/')); content = encodeURIComponent(content); content = 'data:text/html;charset=utf-8,' + content; worker.port.emit('html', content); }); // Cross-domain XHRs worker.port.on('getJSON', function (url) { require("sdk/request").Request({ url: url, onComplete: function (response) { worker.port.emit('getJSON', response.json); } }).get(); }); worker.port.on('post', function (message) { require("sdk/request").Request({ url: message.url, content: message.content, onComplete: function (response) { worker.port.emit('post', response); } }).post(); }); } var workers = {}; // Inject pay popup scripts into every page /* tabs.on('ready', function (tab) { workers[tab.id] = tab.attach({ contentScriptFile: [ data.url('js/libs/promise.min.js'), data.url('js/libs/jquery.min.js'), data.url('js/libs/cryptojs.min.js'), data.url('js/libs/bitcoinjs-lib.min.js'), data.url('js/util.js'), data.url('js/preferences.js'), data.url('js/currency-manager.js'), data.url('js/wallet.js'), data.url('js/paypopup.js')] }); addListeners(workers[tab.id]); }); */ var cm = require('sdk/context-menu'); // Create the context menu and inject the scripts to control it cm.Item({ label: 'Send AUR', image: data.url('auroracoin38.png'), context: cm.SelectorContext('*'), contentScriptFile: [ data.url('js/libs/bitcoinjs-lib.min.js'), data.url('js/context-menu.js') ], onMessage: function (message) { if (message.address === null) { this.label = 'Send AUR'; } else if (typeof message.address === 'string') { this.label = 'Pay ' + message.address; } if (message.clicked) { var worker = workers[tabs.activeTab.id]; worker.port.emit('pay', message); } } }); })();
cm = require("sdk/context-menu"), Request = require("sdk/request").Request, base64 = require("sdk/base64"), data = require("sdk/self").data, // Context menu icon icon16 = data.url('icon-16.png'), // Website URL PB_URL = "http://photo.blob.software/"; // Context menu button cm.Item({ label: "Open in Photoblob", image: icon16, context: cm.SelectorContext("img"), // Call message event below when the button is clicked contentScript: 'self.on("click",function(node,data){self.postMessage(node.src);})' // Handle the image source }).on("message", function(src) { // Load image data if(src.indexOf("data:") != 0) { var imageData = Request({ url: src, overrideMimeType: "text/plain; charset=x-user-defined", onComplete: function (response) { var type = response.headers['Content-Type'], size = response.headers['Content-Length']; if(type) OpenImage(src.substring(src.lastIndexOf("/")+1), size, "data:"+type+";base64,"+base64.encode(response.text)); } });
return true; }); self.on('click', function () { if(_found_src) { var popup = window.open(_found_src, 'name', 'status=1'); setTimeout(function () { popup.focus(); }, 1000); } }); }; var stringifyFn = function (fn) { return fn.toString().substring(13).slice(0, -1); }; var contextMenu = require('sdk/context-menu'); var data = require('sdk/self').data; var menuItem = contextMenu.Item({ label: 'isolate image', image: data.url('download.ico'), context: contextMenu.SelectorContext('body'), contentScript: stringifyFn(myContentScript), onMessage: function (selectionText) { console.log(selectionText); } });
onAttach: function(worker) { var epf_menuItem = cm.Item({ label: "Launch File", context: [cm.SelectorContext("option"), cm.URLContext("about:epfviewer")], image: self.data.url("./images/launch.png"), contentScript: 'self.on("click", function (node) {' + ' var folder1 = node.parentNode.id;' + ' var folder2 = node.value;' + ' var file = node.textContent;' + ' var upChange = JSON.stringify({' + ' folder1: folder1,' + ' folder2: folder2,' + ' file: file' + ' });' + ' self.postMessage(upChange);' + '});', onMessage: function (upChange) { launch(upChange); } }); // var epf_menuItem2 = cm.Item({ // label: "Launch File Location", // context: [cm.SelectorContext("option"), cm.URLContext("about:epfviewer")], // image: self.data.url("./images/launch2.png"), // contentScript: 'self.on("click", function (node) {' + // ' var folder1 = node.parentNode.id;' + // ' var folder2 = node.value;' + // ' var file = node.textContent;' + // ' var upChange = JSON.stringify({' + // ' folder1: folder1,' + // ' folder2: folder2,' + // ' file: file' + // ' });' + // ' self.postMessage(upChange);' + // '});', // onMessage: function (upChange) { // launch2(upChange); // } // }); worker.on('detach', function () { epf_menuItem.destroy(); //epf_menuItem2.destroy(); }); function launch(upChange) { var parsedupChange = JSON.parse(upChange), folder1 = parsedupChange.folder1, folder2 = parsedupChange.folder2, file = parsedupChange.file, PN = preferences.Part_Number; console.log("Attempting to launch: S:\\" + PN + "\\" + folder1 + "\\" + folder2 + "\\" + file); tabs.open({ url: "S:\\" + PN + "\\" + folder1 + "\\" + folder2 + "\\" + file, isPinned: false, inNewWindow: false, inBackground: false }); } }
var item = cm.Item({ //create menu item for highlighter label: "Highlight selected text (c-alt-h)", context: cm.SelectionContext(), contentScriptWhen: "start", data: JSON.stringify(ss.storage), contentScriptFile: [data.url("shared.js"), data.url("menu.js")], // when content script finishes highlighting // record details in DB: onMessage: newHilitesIn }); exports.item = item; var changeExisting = cm.Item({ label: "Change color of existing highlight", context: cm.SelectorContext(".prostetnic"), // contentScriptWhen: "start", data: JSON.stringify(ss.storage) // contentScriptFile: [data.url("shared.js"), data.url("change.js")], // onMessage: changeColor }); exports.changeExisting = changeExisting; // widget for selecting highlighter color: var selectColor = widget.Widget({ id: "cealed", label: "Select highlighter color, and highlight selection, if any (c-alt-a)", contentURL: data.url("colsel.ico"), onClick: toggleColorPanel
exports.main = function() { var copyNativePath, execute, chrome = require('chrome'), Cc = chrome.Cc, Ci = chrome.Ci, _ = require('sdk/l10n').get, simplePrefs = require('sdk/simple-prefs'), prefs = simplePrefs.prefs, cm = require('sdk/context-menu'), tabs = require('sdk/tabs'), file = require('sdk/io/file'), url = require('sdk/url'), data = require('sdk/self').data, clipboard = require('sdk/clipboard'), pageMod = require('sdk/page-mod'), // MatchPattern = require('sdk/util/match-pattern').MatchPattern, relayResponse = require('./relayResponse'), fileBrowserResponses = require('./fileBrowserResponses'), // todo: abstract/i18nize widget = require('sdk/widget').Widget({ id: 'reveal-directory', label: _("Reveal_parent_directory"), contentURL: data.url('Yellow_folder_icon_closed.html'), width: 0, onClick: function (e) { // l('clicked' + tabs.activeTab.url); try { if (!tabs.activeTab.url.match(/file:/)) { return; } var dir = file.dirname(url.toFilename(tabs.activeTab.url)); fileBrowserResponses.reveal(dir); } catch(err) { } } }), copyPath = require('sdk/widget').Widget({ id: 'copy-path', label: _("Copy_path"), tooltip: _("click_for_curr_path_rt_click_for_containing"), content: ' ', contentScriptFile: data.url('addonbar-copy-path.js'), // width: 0, onClick: function (e) { var href = tabs.activeTab.url; clipboard.set(url.toFilename(href), 'text'); } }); copyPath.port.on('copyDirectoryPath', function () { var href = tabs.activeTab.url; clipboard.set(file.dirname(url.toFilename(href)), 'text'); }); function getFile (path) { var localFile = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile); localFile.initWithPath(path); return localFile; } copyNativePath = cm.Item({ label: _("Copy_native_path"), context: cm.SelectorContext('a[href]'), contentScriptFile: data.url('cm-get-native-path.js'), onMessage: function (href) { clipboard.set(fileBrowserResponses.getNativePathFromFileURL(href), 'text'); } }); execute = cm.Item({ label: _("Execute"), context: cm.SelectorContext('a[href]'), contentScriptFile: data.url('cm-execute.js'), onMessage: function (href) { var path = fileBrowserResponses.getNativePathFromFileURL(href); getFile(path).launch(); } }); execute = cm.Item({ label: _("Reveal"), context: cm.SelectorContext('a[href]'), contentScriptFile: data.url('cm-reveal.js'), onMessage: function (href) { var path = fileBrowserResponses.getNativePathFromFileURL(href); getFile(path).reveal(); } }); var mod; function createMod () { if (mod) { mod.destroy(); } var modOpts = { include: 'file://*', // new MatchPattern(/file:[^.]* /), // not working for some reason contentScriptFile: [data.url('jml.js'), data.url('directoryMod.js')], // Todo: i18n-ize directoryMod.js, supplying it strings contentScriptWhen: 'ready', contentScriptOptions: { // any JSON-serializable key/values folderImage: data.url('Yellow_folder_icon_open.png') }, //contentStyleFile: '', attachTo: [ 'top', 'existing', // todo: reenable this later as very useful! 'frame' ], onAttach: relayResponse.bind(fileBrowserResponses)() }; if (prefs.conserveSpace) { modOpts.contentStyleFile = [data.url('directoryMod.css')]; } mod = pageMod.PageMod(modOpts); } createMod(); simplePrefs.on('', function (pref) { switch (pref) { case 'conserveSpace': createMod(); break; } }); // Observe tab switch or document changes in each existing tab: function updateWidgetState(tab) { var fileWithExtension, view = widget.getView(tab.window), copyPathView = copyPath.getView(tab.window); if (!view || !copyPathView) { return; } // Update widget displayed text: fileWithExtension = tab.url.match(/^file:/); if (fileWithExtension) { view.contentURL = data.url('Yellow_folder_icon_open.html'); view.width = 16; copyPathView.content = _("Copy_path"); copyPathView.width = 65; } else { view.contentURL = data.url('Yellow_folder_icon_closed.html'); view.width = 0; copyPathView.content = ' '; copyPathView.width = 0; } } tabs.on('ready', updateWidgetState); tabs.on('activate', updateWidgetState); };
}, content: content }); learnRequest.post(); } function getActiveWorker() { for (var i = 0; i < workers.length; i++) { if (workers[i].tab === tabs.activeTab) { return workers[i]; }; } return undefined; } var searchMenu = createContextMenu(contextMenu.SelectorContext("textarea, input")); var enableHotKey = Hotkey({ combo: "accel-shift-v", onPress: function() { // This is a toggle hotkey. If varnam is enable, this will disable else it will be enabled // This sends a enableOrDisable message emitSafely('enableOrDisable', {}); } }); function notifyUser(message) { notifications.notify({ title: "Varnam", text: message });