👽 Move from GET to POST
This commit is contained in:
parent
a0e3bc77c3
commit
a9ad1533c9
@ -10,10 +10,32 @@ ext.runtime.onMessage.addListener(
|
||||
storage.get(['url', 'token'], function(resp) {
|
||||
url = resp.url;
|
||||
token = resp.token;
|
||||
var destination = url+"?v=1&u="+encodeURIComponent(data.url)+"&t="+encodeURIComponent(data.title)+"&m="+encodeURIComponent(token);
|
||||
fetch(destination).then(function(response) {
|
||||
sendResponse({ action: "saved" });
|
||||
var params = {
|
||||
v: 1,
|
||||
u: encodeURIComponent(data.url),
|
||||
t: encodeURIComponent(data.title),
|
||||
d: encodeURIComponent(data.description),
|
||||
api_token: encodeURIComponent(token),
|
||||
i: encodeURIComponent(data.image),
|
||||
c: encodeURIComponent(data.comment),
|
||||
};
|
||||
var queryString = Object.keys(params).map((key) => {
|
||||
return key + '=' + params[key];
|
||||
}).join('&');
|
||||
fetch(url + "/api/links", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: new URLSearchParams(queryString)
|
||||
})
|
||||
.then(function(response) {
|
||||
sendResponse({ action: "saved" });
|
||||
});
|
||||
// var destination = url+"?v=1&u="+encodeURIComponent(data.url)+"&t="+encodeURIComponent(data.title)+"&m="+encodeURIComponent(token);
|
||||
// fetch(destination).then(function(response) {
|
||||
// sendResponse({ action: "saved" });
|
||||
// });
|
||||
});
|
||||
|
||||
return true; // https://stackoverflow.com/a/20077854
|
||||
|
@ -2,20 +2,23 @@ import ext from "./utils/ext";
|
||||
|
||||
var extractTags = () => {
|
||||
var url = document.location.href;
|
||||
if(!url || !url.match(/^http/)) return;
|
||||
if (!url || !url.match(/^http/)) {
|
||||
console.error("Invalid URL : " + url);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
title: "",
|
||||
description: "",
|
||||
image: "",
|
||||
url: document.location.href
|
||||
url: url
|
||||
};
|
||||
|
||||
var ogTitle = document.querySelector("meta[property='og:title']");
|
||||
if(ogTitle) {
|
||||
data.title = ogTitle.getAttribute("content")
|
||||
data.title = ogTitle.getAttribute("content");
|
||||
} else {
|
||||
data.title = document.title
|
||||
data.title = document.title;
|
||||
}
|
||||
|
||||
var descriptionTag = document.querySelector("meta[property='og:description']") || document.querySelector("meta[name='description']");
|
||||
|
Loading…
Reference in New Issue
Block a user