Skip to content

Commit da310fa

Browse files
committed
Added "selection" on context menus for p2p.
This simplifies sending a plain text p2p URL to Kodi. Just select and right click.
1 parent bd87c14 commit da310fa

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

js/background_scripts/background.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,14 @@ function createHtml5VideoContextMenus() {
280280
}, onContextMenuCreated);
281281
}
282282

283+
function getLinkUrl(infoObject){
284+
var link = infoObject.linkUrl;
285+
if (link === undefined){
286+
link = infoObject.selectionText;
287+
}
288+
return link;
289+
}
290+
283291
function createMagnetAndP2PAndImageContextMenus() {
284292
chrome.contextMenus.create({
285293
title: "Show Image",
@@ -297,12 +305,12 @@ function createMagnetAndP2PAndImageContextMenus() {
297305

298306
chrome.contextMenus.create({
299307
title: "Play now",
300-
contexts: ["link"],
308+
contexts: ["link","selection"],
301309
targetUrlPatterns: ['magnet:*', 'acestream:*', 'sop:*'],
302310
onclick: function (info) {
303311
doAction(actions.Stop, function () {
304-
clearPlaylist(function () {
305-
queueItem(info.linkUrl, function () {
312+
clearPlaylist(function () {
313+
queueItem(getLinkUrl(info), function () {
306314
});
307315
})
308316
});
@@ -311,21 +319,21 @@ function createMagnetAndP2PAndImageContextMenus() {
311319

312320
chrome.contextMenus.create({
313321
title: "Queue",
314-
contexts: ["link"],
322+
contexts: ["link", "selection"],
315323
targetUrlPatterns: ['magnet:*', 'acestream:*', 'sop:*'],
316324
onclick: function (info) {
317-
queueItem(info.linkUrl, function () {
325+
queueItem(getLinkUrl(info), function () {
318326
});
319327
}
320328
}, onContextMenuCreated);
321329

322330
chrome.contextMenus.create({
323331
title: "Play this Next",
324-
contexts: ["link"],
332+
contexts: ["link","selection"],
325333
targetUrlPatterns: ['magnet:*', 'acestream:*', 'sop:*'],
326334
onclick: function (info) {
327335
getPlaylistPosition(function (position) {
328-
insertItem(info.linkUrl, position + 1, function () {
336+
insertItem(getLinkUrl(info), position + 1, function () {
329337
});
330338
});
331339
}

0 commit comments

Comments
 (0)