-
Notifications
You must be signed in to change notification settings - Fork 5
/
bundle.js
236 lines (181 loc) · 7.06 KB
/
bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(1);
module.exports = __webpack_require__(1);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _content = __webpack_require__(2);
var content = _interopRequireWildcard(_content);
var _history = __webpack_require__(3);
var history = _interopRequireWildcard(_history);
var _userPrefs = __webpack_require__(5);
var userPrefs = _interopRequireWildcard(_userPrefs);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var _history = __webpack_require__(3);
(0, _history.searchChromeHistory)().then(function (list) {
var formattedList = R.reduce(_history.listFormatter, '', list);
list.map(function (listItem) {
document.getElementById('list-area').innerHTML += '<p>' + listItem + '</p>';
});
// escaping the ' character, may need to revisit this in the future if more chars cause encoding issues
document.body.innerHTML += "<a class='reading-list' href='data:text;charset=utf-8," + encodeURIComponent(formattedList).replace(/'/g, "%27") + "' download='reading-list'>Download your List</a>";
document.getElementById('number-read').innerHTML = list.length;
});
// leaving this here as it tripped me up for a while. DOMContentLoaded did not appear to be firing
// but apparently content scripts run on their own after the DOM is loaded (at least with
// "start_at" set in manifest.json)
// https://groups.google.com/a/chromium.org/d/msg/chromium-extensions/9bsbgra9QgE/LvbtWPF_QqUJ
// document.addEventListener('DOMContentLoaded', () => {
// DOM code
// })
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.searchChromeHistory = exports.listFormatter = undefined;
var _ramda = __webpack_require__(4);
var _ramda2 = _interopRequireDefault(_ramda);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var dict = ['medium.com', 'quora.com', 'nytimes.com', 'cnn.com', 'newsweek.com', 'blog', 'topic', 'story', 'article'];
//////////////Impure functions/////////////////
var includeUrl = function includeUrl() {
var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
dict.push(item);
};
var removeUrl = function removeUrl() {
var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var index = dict.indexOf(item);
if (index != -1) {
dict.splice(index, 1);
}
};
var getBaseUrl = function getBaseUrl() {
var splitUrl = window.location.href.split('/');
var baseUrl = splitUrl[2];
//common for sites to use 'blog' as subdomain, so we include it
if (splitUrl[3] === 'blog') {
return baseUrl + '/' + splitUrl[3];
}
return baseUrl;
};
var addCurrentPageToDict = function addCurrentPageToDict() {
dict.push(getBaseUrl());
};
var getTodaysDate = function getTodaysDate() {
var date = new Date();
date.setHours(0, 0, 0, 0);
return date.getTime();
};
var searchChromeHistory = function searchChromeHistory() {
return new Promise(function (resolve, reject) {
chrome.history.search({
'text': '', //empty string returns all,
'startTime': getTodaysDate(),
'maxResults': 1000000
}, function (historyItems) {
var list = createList(historyItems);
resolve(list);
});
});
};
//////////////(Mostly) pure functions////////////////
var strBuilder = function strBuilder() {
var a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return a + '|' + b;
};
var listFormatter = function listFormatter(a, b) {
return a + '\n' + b;
};
var createRegexFromDict = function createRegexFromDict() {
var source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
return new RegExp(_ramda2.default.reduce(strBuilder, '', source).slice(1));
};
var isMatch = function isMatch(item) {
return _ramda2.default.test(createRegexFromDict(dict), item.url);
};
var getMatchedItems = _ramda2.default.filter(isMatch);
var getTitle = _ramda2.default.prop('title');
var getTitlesFromHistory = _ramda2.default.compose(_ramda2.default.uniq, _ramda2.default.map(getTitle));
var createList = _ramda2.default.compose(getTitlesFromHistory, getMatchedItems);
var limiter = function limiter(item) {
//if get multiple url's like url/page-1, url/page-2 need to limit
};
exports.listFormatter = listFormatter;
exports.searchChromeHistory = searchChromeHistory;
/***/ },
/* 4 */
/***/ function(module, exports) {
module.exports = R;
/***/ },
/* 5 */
/***/ function(module, exports) {
'use strict';
var saveOptions = function saveOptions() {
chrome.storage.sync.set({
deliveryFrequency: 'daily',
publishingAccount: '' // will be used for later if add ability to publish to Twitter
}, function () {
console.log('Options saved');
});
};
var getOptions = function getOptions() {
chrome.storage.sync.get('deliveryFrequency', function (data) {
console.log('data', data);
});
};
/***/ }
/******/ ]);
//# sourceMappingURL=bundle.js.map