Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
2c2c committed Sep 24, 2017
0 parents commit 8b1ee5d
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
7 changes: 7 additions & 0 deletions background.js
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.
});
});
54 changes: 54 additions & 0 deletions history.js
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);
});
}
)
)
)
)
);
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions manifest.json
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"]
}
20 changes: 20 additions & 0 deletions meme-finder.html
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>

0 comments on commit 8b1ee5d

Please sign in to comment.