Bookmarklet Collection
Published on November 13, 2024 automatization javascriptBookmarklets are bookmarks that, when clicked, execute javascript on the current tab, which opens some interesting opportunities.
ArchiveToday
Redirect the current page to archive.today. Acts like a paywall bypasser.
javascript:location.href='http://archive.today/?run=1&url='+encodeURIComponent(document.location)
olx.ro land price scaper
Useful when researching land price in a certain area. Opens a new tab with a table containing linked titles, location, surface area and price. Note that you must use a bookmarklet creator to compile the code for this one.
Example: turning
this page to:
function zip(arrays) {
return arrays[0].map(function(_,i){
return arrays.map(function(array){return array[i]})
});
};
let titles = [...document.querySelectorAll(".css-u2ayx9 .css-1wxaaza")].map(e => e.innerText.replace(",", ""));
let links = [...document.querySelectorAll("[data-cy=\"ad-card-title\"] .css-z3gu2d")].map(e => e.href);
let linked_title = zip([titles, links]).map(([title, link]) => `<a href="${link}">${title}</a>`);
let cols = {
"location": [...document.querySelectorAll("[data-testid=\"location-date\"]")].map(e => e.innerText.split("-")[0].trim()),
"title": linked_title,
"m^2": [...document.querySelectorAll(".css-1cd0guq")].map(e => e.innerText.replace(/[^0-9]/g, '')),
"price": [...document.querySelectorAll("[data-testid=\"ad-price\"]")].map(e => e.innerText.replace(/[^0-9]/g, ''))
};
let data = zip(Object.values(cols)).map(col => col.map(val => `<td>${val}</td>`).join("")).map(row => `<tr>${row}</tr>`).join("");
let win = window.open('',document.title);
let head = Object.keys(cols).map(e => `<th>${e}</th>`).join("")
win.document.write(`<table><tr>${head}</tr>${data}</table>`);
win.focus();