Entonces, sé que es posible ejecutar JavaScript almacenándolos en el marcador del navegador (también conocido como bookmarklet ), pero no estoy seguro de si es posible usar bookmarklet para editar automáticamente la URL actual (y luego llevarlo a la nueva URL) .
Lo que estoy tratando de hacer:
En la URL, reemplace todo antes ( e incluyendo ) la cadena
/image/thumb/con
https://a1.mzstatic.com/us/r1000/0/y eliminar todo después ( e incluyendo ) el último
/Así, por ejemplo, la siguiente URL:
https://is2-ssl.mzstatic.com/image/thumb/Music/v4/4e/61/09/4e610911-7e0e-d348-8246-11ef6ffe00ab/886443607118.jpg/540x540bb.webpdebe convertirse (y redirigir a)
https://a1.mzstatic.com/us/r1000/0/Music/v4/4e/61/09/4e610911-7e0e-d348-8246-11ef6ffe00ab/886443607118.jpg después de hacer clic en el marcador con JavaScript.
Algunos ejemplos más:
https://is2-ssl.mzstatic.com/image/thumb/Features122/v4/b0/26/80/b0268001-9527-3477-1df2-c68f02271a9f/ffe8be4a-2798-4a68-b691-9a91edb1c177.png/216x216sr.webpdebe convertirse (y redirigir a)
https://a1.mzstatic.com/us/r1000/0/Features122/v4/b0/26/80/b0268001-9527-3477-1df2-c68f02271a9f/ffe8be4a-2798-4a68-b691-9a91edb1c177.png https://is4-ssl.mzstatic.com/image/thumb/Video124/v4/ac/c2/b0/acc2b0a3-8105-2f22-2b0d-ea274223e959/Jobe81235fa-44f7-43f8-a7d6-421093c13e0b-110141253-PreviewImage_preview_image_nonvideo_sdr-Time1616098999993.png/300x300.jpgdebe convertirse (y redirigir a)
https://a1.mzstatic.com/us/r1000/0/Video124/v4/ac/c2/b0/acc2b0a3-8105-2f22-2b0d-ea274223e959/Jobe81235fa-44f7-43f8-a7d6-421093c13e0b-110141253-PreviewImage_preview_image_nonvideo_sdr-Time1616098999993.pngUse String.prototype.match(regExp) para obtener la parte de URL que desea y luego combine la parte de URL con su prefijo de URL.
function replaceUrl(url) { const prefix = 'https://a1.mzstatic.com/us/r1000/0'; const lastPart = url.split("/image/thumb/")[1]; const match = lastPart ? lastPart.slice(0, lastPart.lastIndexOf("/")) : null; const targetUrl = match ? `${prefix}/${match}` : url; return targetUrl; } const targetUrl = replaceUrl('https://is2-ssl.mzstatic.com/image/thumb/Music/v4/4e/61/09/4e610911-7e0e-d348-8246-11ef6ffe00ab/886443607118.jpg/540x540bb.webp');Agregue un bookmarklet, el script del bookmarklet es como:
javascript:(function(){ function replaceUrl(url) { const prefix = 'https://a1.mzstatic.com/us/r1000/0'; const lastPart = url.split("/image/thumb/")[1]; const match = lastPart ? lastPart.slice(0, lastPart.lastIndexOf("/")) : null; const targetUrl = match ? `${prefix}/${match}` : url; return targetUrl; } const targetUrl = replaceUrl(location.href); window.open(targetUrl,"_blank"); })() El location.href es la URL de la pestaña actual, puede cambiarlo a lo que necesite (puede ser la URL de los enlaces de la página actual, etc.). el segundo parámetro de window.open() podría ser _blank (abrir en una pestaña nueva) o _self (abrir en la pestaña actual)