-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"manifest_version": 2, | ||
|
||
"name": "Open in Perplexity", | ||
"description": "Add Perplexity to your context menus.", | ||
"version": "1.0", | ||
|
||
"action": { | ||
"default_icon": "icon.png" | ||
}, | ||
|
||
"permissions": ["contextMenus"], | ||
|
||
"icons": { | ||
"16": "icon.png", | ||
"48": "icon.png", | ||
"128": "icon.png" | ||
}, | ||
|
||
"background": { | ||
"scripts": ["js/background.js"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
const PAGE_ID = "open-in-perplexity" | ||
const SELECTION_ID = "open-in-perplexity-selection" | ||
const P_URL = 'https://www.perplexity.ai?utm_source=oip' | ||
import browser from 'webextension-polyfill' | ||
|
||
const PAGE_ID = "open-in-perplexity"; | ||
const SELECTION_ID = "open-in-perplexity-selection"; | ||
const P_URL = 'https://www.perplexity.ai'; | ||
|
||
chrome.contextMenus.create({ | ||
browser.contextMenus.create({ | ||
id: SELECTION_ID, | ||
title: 'Perplexity "%s"', | ||
contexts: ['selection'] | ||
}); | ||
|
||
chrome.contextMenus.create({ | ||
browser.contextMenus.create({ | ||
id: PAGE_ID, | ||
title: 'Open Perplexity', | ||
contexts: ['page', 'frame'] | ||
}); | ||
|
||
|
||
|
||
chrome.contextMenus.onClicked.addListener(function (info, tab) { | ||
browser.contextMenus.onClicked.addListener((info, tab) => { | ||
if (info.menuItemId === SELECTION_ID) { | ||
chrome.tabs.create({ url: P_URL + `&q=${info.selectionText}` }); | ||
browser.tabs.create({ url: P_URL + `?q=${info.selectionText}` }); | ||
} else if (info.menuItemId === PAGE_ID) { | ||
chrome.tabs.create({ url: P_URL }); | ||
browser.tabs.create({ url: P_URL }); | ||
} | ||
}); | ||
|
||
chrome.action.onClicked.addListener((tab) => { | ||
chrome.tabs.create({ url: P_URL }); | ||
}); | ||
browser.action.onClicked.addListener((tab) => { | ||
browser.tabs.create({ url: P_URL }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters