mirror of
https://github.com/slynn1324/tinypin.git
synced 2026-01-23 02:25:08 +00:00
Merge branch 'master' of github.com:slynn1324/tinypin
This commit is contained in:
commit
28f689749f
4 changed files with 72 additions and 10 deletions
|
|
@ -21,7 +21,7 @@ function getClickHandler() {
|
|||
// strip the google images redirect
|
||||
if ( s.startsWith("https://www.google.com/url?") ){
|
||||
let parts = s.split("?");
|
||||
alert("parts length= " + parts.length);
|
||||
|
||||
if ( parts.length == 2 ){
|
||||
|
||||
let params = parts[1].split("&");
|
||||
|
|
@ -29,8 +29,6 @@ function getClickHandler() {
|
|||
for( let i = 0; i < params.length; ++i ){
|
||||
let kv = params[i].split("=");
|
||||
|
||||
alert(JSON.stringify(kv));
|
||||
|
||||
if ( kv.length == 2 ){
|
||||
if ( kv[0] == "url" ){
|
||||
s = decodeURIComponent(kv[1]);
|
||||
|
|
@ -50,12 +48,24 @@ function getClickHandler() {
|
|||
|
||||
var q = "i=" + encodeURIComponent(info.srcUrl) + "&s=" + s;
|
||||
|
||||
// The srcUrl property is only available for image elements.
|
||||
var url = 'http://localhost:3000/addpin.html#' + q;
|
||||
|
||||
// Create a new window to the info page.
|
||||
// chrome.windows.create({ url: url, width: 520, height: 660 });
|
||||
chrome.windows.create({ url: url, width: w, height: h, left: left, top: top, type: 'popup' });
|
||||
|
||||
chrome.storage.sync.get({
|
||||
server: 'http://localhost:3000'
|
||||
}, function(items){
|
||||
let server = items.server;
|
||||
|
||||
if ( !server.endsWith('/') ){
|
||||
server += '/';
|
||||
}
|
||||
|
||||
var url = server + 'addpin.html#' + q;
|
||||
|
||||
// Create a new window to the info page.
|
||||
// chrome.windows.create({ url: url, width: 520, height: 660 });
|
||||
chrome.windows.create({ url: url, width: w, height: h, left: left, top: top, type: 'popup' });
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,13 @@
|
|||
"description": "add to tinypin context menu plugin",
|
||||
"manifest_version": 2,
|
||||
"background" : { "scripts": ["background.js"] },
|
||||
"options_ui" : {
|
||||
"page": "options.html",
|
||||
"open_in_tab": false
|
||||
},
|
||||
"permissions" : [
|
||||
"contextMenus"
|
||||
"contextMenus",
|
||||
"storage"
|
||||
],
|
||||
"icons": {
|
||||
"16" : "icon16.png",
|
||||
|
|
|
|||
22
chrome-extension/options.html
Normal file
22
chrome-extension/options.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>tinypin options</title>
|
||||
</head>
|
||||
<body style="font-size: 1em;">
|
||||
|
||||
<label for="server">server url</label>
|
||||
<div>
|
||||
<input type="text" id="server" style="width: 95%; font-size: 1em;"/>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
|
||||
<button id="save">Save</button>
|
||||
<span id="status" style="color: green;"></span>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
25
chrome-extension/options.js
Normal file
25
chrome-extension/options.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
function restoreOptions(){
|
||||
chrome.storage.sync.get({
|
||||
server: 'http://localhost:3000'
|
||||
}, function(items){
|
||||
document.getElementById('server').value = items.server;
|
||||
});
|
||||
}
|
||||
|
||||
function saveOptions(){
|
||||
let server = document.getElementById('server').value;
|
||||
|
||||
chrome.storage.sync.set({
|
||||
server: server
|
||||
}, function(){
|
||||
let status = document.getElementById('status');
|
||||
status.innerText = 'Options saved.';
|
||||
setTimeout(function(){
|
||||
status.innerText = '';
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', restoreOptions);
|
||||
document.getElementById('save').addEventListener('click', saveOptions);
|
||||
Loading…
Add table
Add a link
Reference in a new issue