You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this is a bit tricky. I have tried to work on this, with the following results.
The context menu can be enabled for the Chrome pdf plugin using
contexts: ['all']
instead of
contexts: ['frame'].
Then, one can use
var url = clickData.srcUrl || clickData.frameUrl || clickData.pageUrl;
to obtain the url to the pdf file in the onClicked listener.
However, tab.id == -1. This is where I am stuck. Are plugin extensions living in some invalid tab rather than the real one? Is this a Chromium bug? Can one maybe use the currently active tab instead?
The text was updated successfully, but these errors were encountered:
Alright, I fixed this. So in addition to the above changes to the contexts (from 'frame' to 'all'), this solves my problem:
chrome.contextMenus.onClicked.addListener(function(clickData, tab) {
var handler = COMMANDS[clickData.menuItemId].handler;
if (tab.id == -1) {
// for example, when in pdf plugin
var url = clickData.srcUrl;
chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
handler(url, tabs[0]);
});
} else {
var url = clickData.frameUrl || clickData.pageUrl;
handler(url, tab);
}
});
There may be some more testing required, but I like it so far.
did you find out the real problem?
i have the same issue when i have a pdf file:
when clicking on my context menu (chrome.contextMenus.onClicked), I get tab.id == -1.
however, if i click on my browserAction icon (chrome.browserAction.onClicked), I get the valid tab.id.
any idea of why?
I would love to use this extension to free some pdf from iframes, such as this one:
http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6919256
However, this is a bit tricky. I have tried to work on this, with the following results.
The context menu can be enabled for the Chrome pdf plugin using
contexts: ['all']
instead of
contexts: ['frame'].
Then, one can use
var url = clickData.srcUrl || clickData.frameUrl || clickData.pageUrl;
to obtain the url to the pdf file in the onClicked listener.
However, tab.id == -1. This is where I am stuck. Are plugin extensions living in some invalid tab rather than the real one? Is this a Chromium bug? Can one maybe use the currently active tab instead?
The text was updated successfully, but these errors were encountered: