Skip to content

Commit 682908f

Browse files
feature/history
Feature/history
2 parents c1faa43 + 9f5ced2 commit 682908f

17 files changed

+549
-59
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Assets
44
- [kutt.it API](https://github.com/thedevs-network/kutt#api) is used to retreive shortened URLs.
5+
- [node-kutt](https://github.com/ardalanamini/node-kutt) is used for API calls
56

67
## Development
78
- `npm install` to install dependencies.
@@ -53,6 +54,9 @@ height="50">](https://github.com/abhijithvijayan/kutt-extension/releases)
5354
- [x] Fix UI issues in Firefox
5455
- [x] Using Node-Kutt package(feature request)
5556
- [ ] History Feature
57+
- [ ] Context Menu
58+
- [ ] Auto Copy Clipboard
59+
- [ ] Toggleable Options
5660

5761

5862
## Note:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
- Paste and Save this `Key` in extension's `options page` when asked.
5454

5555
<img width="250" src="https://i.imgur.com/fJasvmv.png" alt="image2" />
56+
57+
<hr />
5658

5759
## Screenshots
5860

src/assets/delete.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/history.svg

Lines changed: 1 addition & 0 deletions
Loading

src/history.html

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>History: Kutt</title>
9+
<link rel="stylesheet" href="css/history.css" />
10+
</head>
11+
12+
<body>
13+
<section id="history">
14+
<div class="container history__content--holder">
15+
<div class="table__content--holder">
16+
<h2 class="table__content--title">Recent shortened links.</h2>
17+
<table class="table__content--wrapper" id="URL_table">
18+
<thead class="table__content--head">
19+
<tr class="table__head--holder">
20+
<th class="table__head--longURL">
21+
Original URL
22+
</th>
23+
<th class="table__head--shortURL">
24+
Short URL
25+
</th>
26+
<th class="table__head--clearAll">
27+
<ul class="table__list--clearAll">
28+
<li class="table__listItem--clear">
29+
<button class="table__clearAll--btn" id="table__clearAll--btn" title="Delete All">
30+
Clear All <img class="selectDisable icon__img" src="assets/delete.svg" alt="Delete All" />
31+
</button>
32+
</li>
33+
</ul>
34+
</th>
35+
</tr>
36+
</thead>
37+
<tbody class="table__content--body" id="delegation__element">
38+
<!-- TEMPLATE TO USE -->
39+
<!-- <tr class="table__body--holder">
40+
<td class="table__body--original">
41+
<a href="#" class="table__body--originalURL" target="_blank" rel="noopener">https://google.com</a>
42+
</td>
43+
<td class="table__body--shortened">
44+
<div class="table__body--shortenBody">
45+
<a href="#" class="table__body--shortenURL" target="_blank" rel="noopener">https://kutt.it/abc</a>
46+
</div>
47+
</td>
48+
<td class="table__body--functionBtns">
49+
<div class="table__body--btnHolder">
50+
<button class="table__body--copy" title="Copy">
51+
<img class="selectDisable icon__img" src="assets/copy.svg" alt="copy" />
52+
</button>
53+
<button class="table__body--qrcode" title="QR Code">
54+
<img class="selectDisable icon__img" src="assets/qrcode.svg" alt="QR Code" />
55+
</button>
56+
</div>
57+
<div class="table__qrcodePopup--div">
58+
<div class="table__qrcode--popup">
59+
<div class="table__qrcode--holder">
60+
<img id="table__qrcode" src="#" alt="QRCode" />
61+
</div>
62+
<div class="table__closebtn--holder">
63+
<button class="table__closebtn--inner">Close</button>
64+
</div>
65+
</div>
66+
</div>
67+
</td>
68+
</tr> -->
69+
</tbody>
70+
</table>
71+
</div>
72+
</div>
73+
</section>
74+
75+
<script src="js/history.js"></script>
76+
</body>
77+
78+
</html>

src/manifest.chrome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "Kutt",
4-
"version": "0.8.0",
4+
"version": "0.9.0",
55
"description": "URL Shortener",
66
"icons": {
77
"16": "assets/favicon-16.png",

src/manifest.firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "Kutt",
4-
"version": "0.8.0",
4+
"version": "0.9.0",
55
"browser_specific_settings": {
66
"gecko": {
77

src/manifest.opera.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "Kutt",
4-
"version": "0.8.0",
4+
"version": "0.9.0",
55
"description": "URL Shortener",
66
"developer": {
77
"name": "abhijithvijayan"

src/popup.html

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,52 @@
22
<html lang="en">
33

44
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8-
<title>Kutt</title>
9-
<link rel="stylesheet" href="css/popup.css" />
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Kutt</title>
9+
<link rel="stylesheet" href="css/popup.css" />
1010
</head>
1111

1212
<body>
13-
<section id="home">
14-
<div class="container">
15-
<nav class="navbar">
16-
<ul class="navbar__main">
17-
<li class="logo__content--holder">
18-
<img class="main__logo selectDisable" src="assets/logo.png">
19-
</li>
20-
<li class="options__content-holder" id="options__content-holder" title="Options">
21-
<a href="options.html" target="_blank" rel="noopener">
22-
<img class="settings__logo selectDisable" src="assets/settings.svg"></a>
23-
</li>
24-
</ul>
25-
</nav>
26-
<div class="content__holder">
27-
<div class="url__content--holder text-center">
28-
<h4 id="url__content-inner">Shortening...</h4>
29-
<ul class="buttons__content--holder d-none">
30-
<li class="copy__content--holder" id="button__copy--holder" title="Copy">
31-
<img id="button__copy" class="selectDisable" src="assets/copy.svg" alt="copy" />
32-
</li>
33-
<li class="qrbtn__content--holder" id="button__qrcode--holder" title="QR code">
34-
<img id="button__qrcode" class="selectDisable" src="assets/qrcode.svg" alt="QR Code" />
35-
</li>
36-
</ul>
13+
<section id="home">
14+
<div class="container">
15+
<nav class="navbar">
16+
<ul class="navbar__main">
17+
<li class="logo__content--holder">
18+
<img class="main__logo selectDisable" src="assets/logo.png">
19+
</li>
20+
<li class="options__content-holder" id="options__content-holder" title="History">
21+
<a href="history.html" target="_blank" rel="noopener">
22+
<img class="settings__logo selectDisable" src="assets/history.svg"></a>
23+
</li>
24+
<li class="options__content-holder" id="options__content-holder" title="Options">
25+
<a href="options.html" target="_blank" rel="noopener">
26+
<img class="settings__logo selectDisable" src="assets/settings.svg"></a>
27+
</li>
28+
</ul>
29+
</nav>
30+
<div class="content__holder">
31+
<div class="url__content--holder text-center">
32+
<h4 id="url__content-inner">Shortening...</h4>
33+
<ul class="buttons__content--holder d-none">
34+
<li class="copy__content--holder" id="button__copy--holder" title="Copy">
35+
<img id="button__copy" class="selectDisable" src="assets/copy.svg" alt="copy" />
36+
</li>
37+
<li class="qrbtn__content--holder" id="button__qrcode--holder" title="QR code">
38+
<img id="button__qrcode" class="selectDisable" src="assets/qrcode.svg" alt="QR Code" />
39+
</li>
40+
</ul>
41+
</div>
42+
<p class="copy__alert text-center d-none">Copied!!!</p>
43+
<div class="qrcode__content--holder text-center d-none">
44+
<img id="qr_code" src="#" alt="QRCode" />
45+
</div>
46+
</div>
3747
</div>
38-
<p class="copy__alert text-center d-none">Copied!!!</p>
39-
<div class="qrcode__content--holder text-center d-none">
40-
<img id="qr_code" src="#" alt="QRCode" />
41-
</div>
42-
</div>
43-
</div>
44-
</section>
48+
</section>
4549

46-
<script src="js/popup.js"></script>
50+
<script src="js/popup.js"></script>
4751
</body>
4852

4953
</html>

src/scripts/background.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Kutt from 'kutt';
22
import browser from 'webextension-polyfill';
33

4+
let URLs_array = [];
5+
46
// Shorten url
57
async function getShortURL(API_key, URLtoShorten, password) {
68
const kutt = new Kutt();
@@ -30,11 +32,24 @@ async function getShortURL(API_key, URLtoShorten, password) {
3032

3133
// Calling function
3234
browser.runtime.onMessage.addListener(async (request, sender, response) => {
33-
if (request.msg == 'start') {
35+
// get the url shorten request from popup.js
36+
if (request.msg === 'start') {
3437
// consume the promise
3538
return getShortURL(request.API_key, request.pageUrl, request.password)
3639
.then(shortLink => {
3740
return shortLink;
3841
});
3942
}
43+
// store urls to history
44+
if (request.msg === 'store') {
45+
if (request.count >= 10) {
46+
// delete first element
47+
URLs_array.shift();
48+
browser.storage.local.set({ count: --request.count });
49+
}
50+
if (request.count < 10) {
51+
URLs_array.push(request.URLs);
52+
browser.storage.local.set({ URL_array: URLs_array, count: ++request.count });
53+
}
54+
}
4055
});

0 commit comments

Comments
 (0)