mirror of
https://github.com/slynn1324/tinypin.git
synced 2026-01-23 02:25:08 +00:00
fix up chrome extension
This commit is contained in:
parent
928c1c9903
commit
83f178d6e4
2 changed files with 40 additions and 2 deletions
|
|
@ -14,7 +14,41 @@ function getClickHandler() {
|
|||
var left = (screen.width/2)-(w/2);
|
||||
var top = (screen.height/2)-(h/2);
|
||||
|
||||
var q = "i=" + encodeURIComponent(info.srcUrl) + "&s=" + encodeURIComponent(tab.url);
|
||||
let s = "";
|
||||
if ( info.linkUrl ){
|
||||
s = info.linkUrl;
|
||||
|
||||
// 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("&");
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s = encodeURIComponent(s);
|
||||
|
||||
} else {
|
||||
s = encodeURIComponent(info.pageUrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,11 @@ app.addSetter("load.boards", async (data) => {
|
|||
|
||||
data.initialized = true;
|
||||
|
||||
data.addPinModal.boardId = data.boards[0].id;
|
||||
if ( data.boards && data.boards.length > 0 ){
|
||||
data.addPinModal.boardId = data.boards[0].id;
|
||||
} else {
|
||||
data.addPinModal.boardId = "new";
|
||||
}
|
||||
|
||||
store.do("loader.hide");
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue