Clipper: Clean up

pull/4106/head
Laurent Cozic 2018-05-16 14:21:33 +01:00
parent 6c5d208893
commit c96a416c2c
6 changed files with 6 additions and 2618 deletions
Clipper/joplin-webclipper

View File

@ -1 +1,3 @@
// Add here all the external scripts that the content script might need
// and run browserify on it to create vendor.bundle.js
const Readability = require('readability-node').Readability;

View File

@ -1,3 +0,0 @@
//document.body.style.border = "5px solid red";
// const Readability = require('readability-node').Readability;

File diff suppressed because it is too large Load Diff

View File

@ -1,145 +0,0 @@
/**
* CSS to hide everything on the page,
* except for elements that have the "beastify-image" class.
*/
const hidePage = `body > :not(.beastify-image) {
display: none;
}`;
/**
* Listen for clicks on the buttons, and send the appropriate message to
* the content script in the page.
*/
function listenForClicks() {
document.addEventListener('click', async (event) => {
const tabs = await browser.tabs.query({active: true, currentWindow: true});
const html = await browser.tabs.sendMessage(tabs[0].id, {
command: "getCompletePageHtml",
});
console.info('RRRRRRRRR', html);
});
// console.info('Listin');
// document.addEventListener("click", (event) => {
// /**
// * Insert the page-hiding CSS into the active tab,
// * then get the beast URL and
// * send a "beastify" message to the content script in the active tab.
// */
// // function beastify(tabs) {
// // browser.tabs.insertCSS({code: hidePage}).then(() => {
// // let url = beastNameToURL(e.target.textContent);
// // browser.tabs.sendMessage(tabs[0].id, {
// // command: "beastify",
// // beastURL: url
// // });
// // });
// // }
// // *
// // * Remove the page-hiding CSS from the active tab,
// // * send a "reset" message to the content script in the active tab.
// // function reset(tabs) {
// // browser.tabs.removeCSS({code: hidePage}).then(() => {
// // browser.tabs.sendMessage(tabs[0].id, {
// // command: "reset",
// // });
// // });
// // }
// /**
// * Just log the error to the console.
// */
// function reportError(error) {
// console.error(`Could not beastify: ${error}`);
// }
// // const action = event.currentTarget.getAttribute('data-action');
// console.info(event.currentTarget);
// /**
// * Get the active tab,
// * then call "beastify()" or "reset()" as appropriate.
// */
// // if (e.target.classList.contains("beast")) {
// // browser.tabs.query({active: true, currentWindow: true})
// // .then(beastify)
// // .catch(reportError);
// // }
// // else if (e.target.classList.contains("reset")) {
// // browser.tabs.query({active: true, currentWindow: true})
// // .then(reset)
// // .catch(reportError);
// // }
// });
}
/**
* There was an error executing the script.
* Display the popup's error message, and hide the normal UI.
*/
function reportExecuteScriptError(error) {
document.querySelector("#popup-content").classList.add("hidden");
document.querySelector("#error-content").classList.remove("hidden");
console.error(`Failed to execute beastify content script: ${error.message}`);
}
browser.runtime.onMessage.addListener(notify);
function notify(message) {
if (message.command === 'setCompletePageHtml') {
console.info('UUUUUUUUUUUUU', message.baseUrl);
fetch("http://127.0.0.1:9967/notes", {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
//make sure to serialize your JSON body
body: JSON.stringify({
title: message.title,
baseUrl: message.baseUrl,
bodyHtml: message.html,
url: message.url,
})
})
.then( async (response) => {
console.info('GOT RESPNSE', response);
const json = await response.json();
console.info(json);
//do something awesome that makes the world a better place
});
// console.info('aaaaaaaaaa', message.html);
}
//console.info('Popup: got message', message);
// browser.notifications.create({
// "type": "basic",
// "iconUrl": browser.extension.getURL("link.png"),
// "title": "You clicked a link!",
// "message": message.url
// });
}
/**
* When the popup loads, inject a content script into the active tab,
* and add a click handler.
* If we couldn't inject the script, handle the error.
*/
browser.tabs.executeScript({file: "/content_scripts/vendor.bundle.js"})
.then(() => {
return browser.tabs.executeScript({file: "/content_scripts/index.js"})
})
.then(listenForClicks)
.catch(reportExecuteScriptError);

View File

@ -2,29 +2,4 @@
text-align: center;
width: 400px;
height: 400px;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
}
.App-title {
font-size: 1.5em;
}
.App-intro {
font-size: large;
}
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
}

View File

@ -24,6 +24,8 @@
"_mydocs/EnexSamples/*.enex",
"*.min.css",
"*.min.js",
"*.bundle.js",
"yarn.lock",
],
"folder_exclude_patterns":
[
@ -58,6 +60,7 @@
"ElectronClient/app/dist",
"_releases",
"ReactNativeClient/lib/csstojs",
"Clipper/joplin-webclipper/popup/build",
],
"path": "."
},