Skip to content

Instantly share code, notes, and snippets.

@coreequip
Last active November 3, 2020 15:23
Show Gist options
  • Save coreequip/cc1d66a3bd590fab8676d73b36341ad1 to your computer and use it in GitHub Desktop.
Save coreequip/cc1d66a3bd590fab8676d73b36341ad1 to your computer and use it in GitHub Desktop.
Bookmarklet that copies a shortened URL from popular shopping sites into the clipboard.

Shorty

Bookmarklet that copies a shortened URL from popular shopping sites into the clipboard.

Just drag & drop this link -> Shorty <- to your bookmark bar. Edit it an paste as URL this text:

javascript:u=location.href;[[/^(https?:\/\/[a-z]+\.aliexpress\.com\/item\/[0-9]+\.html)\??.*$/,'$1'],[/^(https?:\/\/www\.ebay(?:\.[a-z]+)+\/itm\/)[^\/]+(\/[0-9]+)\??.*$/,'$1-$2'],[/^(https?:\/\/www\.gearbest\.com\/)[^\/]+(\/pp_[0-9]+\.html)\??.*$/,'$1-$2'],[/^(https?:\/\/\w+\.amazon\.[\w.]+\/).*?\/(B[A-Z0-9]+).*$/,'$1dp/$2'],[/^(https?:\/\/\w+\.alternate\.de\/).*?\/(product\/\d+).*$/,'$1$2'],[/^(https?:\/\/\w+\.conrad\.de\/).*?-(\d+\.html).*$/,'$1$2'],[/^(https:\/\/\www\.heise\.de\/).*(-\d+)\.html/,'$1$2'],[/^(https:\/\/\www\.golem\.de\/).*-(\d+)-(\d+)\.html/,'$1$2/$3']].forEach(r=>u=u.replace(r[0],r[1]));d=document;t=d.createElement('textarea');t.textContent=u;d.body.appendChild(t);s=d.getSelection();s.removeAllRanges();t.select();d.execCommand('copy');s.removeAllRanges();d.body.removeChild(t);void(0)

Current supported sites:

  • aliexpress.com
  • amazon.com/.de/.??
  • ebay.com/.de/.??
  • gearbest.com
  • alternate.de
  • conrad.de
  • heise.de
  • golem.de
u = location.href;
[
[/^(https?:\/\/[a-z]+\.aliexpress\.com\/item\/[0-9]+\.html)\??.*$/, '$1'],
[/^(https?:\/\/www\.ebay(?:\.[a-z]+)+\/itm\/)[^\/]+(\/[0-9]+)\??.*$/, '$1-$2'],
[/^(https?:\/\/www\.gearbest\.com\/)[^\/]+(\/pp_[0-9]+\.html)\??.*$/, '$1-$2'],
[/^(https?:\/\/\w+\.amazon\.[\w.]+\/).*?\/(B[A-Z0-9]+).*$/, '$1dp/$2'],
[/^(https?:\/\/\w+\.alternate\.de\/).*?\/(product\/\d+).*$/, '$1$2'],
[/^(https?:\/\/\w+\.conrad\.de\/).*?-(\d+\.html).*$/, '$1$2'],
[/^(https:\/\/\www\.heise\.de\/).*(-\d+)\.html/, '$1$2'],
[/^(https:\/\/\www\.golem\.de\/).*-(\d+)-(\d+)\.html/, '$1$2/$3']
].forEach(r => u = u.replace(r[0], r[1]));
d = document;
t = d.createElement('textarea');
t.textContent = u;
d.body.appendChild(t);
s = d.getSelection();
s.removeAllRanges();
t.select();
d.execCommand('copy');
s.removeAllRanges();
d.body.removeChild(t);
void(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment