Skip to content

Commit

Permalink
Merge pull request #50 from Catmaniscatlord/main
Browse files Browse the repository at this point in the history
PDF detection change
  • Loading branch information
do-me committed Apr 30, 2024
2 parents c24ed0d + 1ffe9c0 commit 534356d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions extension/public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "0.0.1",
"host_permissions": ["http://*/*", "https://*/*"],
"permissions": [
"scripting",
"activeTab",
"storage",
"unlimitedStorage"
Expand Down
4 changes: 2 additions & 2 deletions extension/src/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ chrome.runtime.onMessage.addListener(async function(request, sender) {
if (request.type === "getText") {
const numChars = await fetchNumChars();
let texts = [];
// hacky support for pdf
if (currentURL.includes('pdf')) {

if (request.contentType == "application/pdf") {
let textContent = await fetchAndExtractPDFText(currentURL);
texts = splitReadableContent(textContent, numChars);

Expand Down
12 changes: 11 additions & 1 deletion extension/src/popup/popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@ export default {
chrome.runtime.onMessage.addListener(this.handleMessage);
const [tab] = await chrome.tabs.query({active: true, currentWindow: true});
chrome.tabs.sendMessage(tab.id, {type: "getText"});
const [res] = await chrome.scripting.executeScript({
target: { tabId: tab.id },
func: () => {
return document.contentType;
},
});
chrome.tabs.sendMessage(tab.id, {
type: "getText",
contentType: res.result,
});
chrome.runtime.sendMessage({type: "load"});
this.results = [];
Expand Down

0 comments on commit 534356d

Please sign in to comment.