-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 8b1ee5d
Showing
5 changed files
with
97 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
chrome.browserAction.onClicked.addListener(function(tab) { | ||
chrome.tabs.create({ url: chrome.extension.getURL("meme-finder.html") }, function( | ||
tab | ||
) { | ||
// Tab opened. | ||
}); | ||
}); |
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,54 @@ | ||
// lol | ||
chrome.history.search( | ||
{ text: "jpg", startTime: 0, maxResults: 99999 }, | ||
jpg_items => | ||
chrome.history.search( | ||
{ text: "png", startTime: 0, maxResults: 99999 }, | ||
png_items => | ||
chrome.history.search( | ||
{ text: "gif", startTime: 0, maxResults: 99999 }, | ||
gif_items => | ||
chrome.history.search( | ||
{ text: "gifv", startTime: 0, maxResults: 99999 }, | ||
gifv_items => | ||
chrome.history.search( | ||
{ text: "webm", startTime: 0, maxResults: 99999 }, | ||
webm_items => { | ||
// merge all the item search results and clean up false positives | ||
let items = jpg_items | ||
.concat(png_items) | ||
// gif_items covers both .gif and .gifv search results | ||
.concat(gif_items) | ||
.concat(webm_items) | ||
.filter(i => { | ||
let is_match = | ||
/.*jpg$/.test(i.url) || | ||
/.*png$/.test(i.url) || | ||
/.*gif$/.test(i.url) || | ||
/.*gifv$/.test(i.url) || | ||
/.*webm$/.test(i.url); | ||
|
||
return is_match; | ||
}) | ||
.sort((a, b) => b.lastVisitTime - a.lastVisitTime); | ||
|
||
// attach children img elements to #id using data from items | ||
items.forEach(i => { | ||
let ele = document.createElement("img"); | ||
// gifv -> gif extension hack to fix embedding | ||
let re = /.*gifv$/; | ||
if (i.url.match(re)) { | ||
console.log(i.url); | ||
i.url = i.url.substring(0, i.url.length - 1); | ||
} | ||
ele.setAttribute("src", i.url); | ||
ele.setAttribute("width", "500px"); | ||
ele.setAttribute("height", "500px"); | ||
document.getElementById("container").appendChild(ele); | ||
}); | ||
} | ||
) | ||
) | ||
) | ||
) | ||
); |
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,16 @@ | ||
{ | ||
"manifest_version": 2, | ||
|
||
"name": "meme finder", | ||
"description": | ||
"display media files in your browser history", | ||
"version": "1.0", | ||
|
||
"background": { | ||
"scripts": ["background.js"] | ||
}, | ||
"browser_action": { | ||
"default_icon": "icon.png" | ||
}, | ||
"permissions": ["activeTab", "tabs", "storage", "history"] | ||
} |
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,20 @@ | ||
<!doctype html> | ||
<html> | ||
|
||
<head> | ||
<title>Memes</title> | ||
<script type="text/javascript" src="history.js"></script> | ||
<style> | ||
#container { | ||
width: 1500px; | ||
margin: 0 auto; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="container"> | ||
</div> | ||
</body> | ||
|
||
</html> |