Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
syncfusion-ebook-links
{
"manifest_version": 2,
"name": "Syncfusion e-book links",
"description": "Replace DOWNLOAD buttons by convenient links",
"version": "1.0",
"content_scripts": [ {
"js": [ "jquery-1.11.1.min.js", "script.js" ],
"matches": [ "https://www.syncfusion.com/resources/techportal/ebooks" ]
} ]
}
function generateMarkDown() {
var origin = document.location.origin;
var books = $("#layout22a > div > div > div").map(function() {
var title = $(this).find("h3 a").text().trim();
var img = origin + $(this).find("img").attr('src');
var pdf = origin + $(this).find("a.download:eq(0)").attr("href");
var mobi = origin + $(this).find("a.download:eq(1)").attr("href");
return "# " + title + "\n![" +title+"]("+ img +")\n* [Download PDF]("+pdf+")\n* [Download MOBI]("+mobi + ")\n";
});
books.sort();
var md = ""
for (var i = 0; i < books.length; i++) {
md += books[i] + "\n";
};
console.log(md);
}
function replaceNextButton() {
var button = $("p.download-btn input")[0];
if (button == undefined) {
console.log("All buttons replaced");
generateMarkDown();
return;
}
console.log("Replacing " + button.name + "...");
$.post("https://www.syncfusion.com/resources/techportal/ebooks",
"downloadURL=%2Fresources%2Ftechportal%2Febooks%2F"+button.name,
function(data) {
var links = $("a.download", data);
if (links.length>0) {
console.log("Replacing " + button.name + "... OK");
$(button).replaceWith(links);
}
else {
console.log("Replacing " + button.name + "... Failed");
}
replaceNextButton();
});
}
replaceNextButton();
@Testato
Copy link

Testato commented Apr 1, 2015

your wget script not work anymore, it download only a 40KB pdf and 40KB mobi but empty
wget -A pdf,mobi -r -l1 -H -nd https://blog.benoitblanchon.fr/syncfusion-ebooks-links/ -e robots=off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment