save and load state
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
<link>
|
||||
<meta charset="utf-8">
|
||||
<title>Data Extractor</title>
|
||||
<script charset="UTF-8" type="text/javascript" src="../scripts/shared/common.js"></script>
|
||||
<script charset="UTF-8" type="text/javascript" src="tip.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="styles/bootstrap.min.css">
|
||||
@ -32,7 +33,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
<h6>Quick Start</h6>
|
||||
</div>
|
||||
@ -42,22 +42,33 @@
|
||||
<div class="alert alert-success small">
|
||||
<p>
|
||||
<b>Extract current page</b>:
|
||||
<br>new Extractor().task(".list-item", ["a.title", "p.content"]).start();
|
||||
<br>> $(".list-item", ["a.title", "p.content"]);
|
||||
</p>
|
||||
<p>
|
||||
<b>Extract multiple pages (1-10, interval 1)</b>:
|
||||
<br>new Extractor().task(".list-item", ["a.title", "p.content"],
|
||||
"http://sample.com/?pn=${page}", 1, 10, 1).start();
|
||||
<br>> job=new Extractor().task(".list-item", ["a.title", "p.content"],
|
||||
"http://sample.com/?pn=${page}", 1, 10, 1);
|
||||
<br>> job.start();
|
||||
|
||||
</p>
|
||||
<p>
|
||||
<b>Full document:</b>
|
||||
<b>Full document at:</b>
|
||||
<br>
|
||||
<a href="#" id="link-document">https://git.jebbs.co/jebbs/data-extracter-extesion</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h6>Saved State</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input type="file" name="state" id="state-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
18
popup/tip.js
18
popup/tip.js
@ -11,4 +11,22 @@ window.onload = function () {
|
||||
'url': `https://git.jebbs.co/jebbs/data-extracter-extesion`
|
||||
});
|
||||
})
|
||||
document.querySelector('#state-input')
|
||||
.addEventListener('change', function (...args) {
|
||||
if (this.files.length == 1) {
|
||||
var reader = new FileReader();
|
||||
let fileName = this.files[0].name;
|
||||
reader.readAsText(this.files[0], "UTF-8");
|
||||
reader.onload = function (evt) {
|
||||
var fileString = evt.target.result;
|
||||
chrome.runtime.sendMessage({
|
||||
action: ACTION_UPLOAD_STATE,
|
||||
state: fileString,
|
||||
name: fileName
|
||||
}, r => {
|
||||
if (r) console.log('State sent:', r);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user