Guest User

Untitled

a guest
May 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
  2. (function(){
  3. var url=document.location;
  4. var links=document.getElementsByTagName('link');
  5. var found=0;
  6. for(var i = 0, l; l = links[i]; i++) {
  7. if (l.getAttribute('rev') == 'canonical' || (/alternate short/).exec(l.getAttribute('rel'))) {
  8. found=l.getAttribute('href');
  9. break;
  10. }
  11. }
  12. if (!found) {
  13. for (var i = 0; l = document.links[i]; i++) {
  14. if (l.getAttribute('rev') == 'canonical') {
  15. found = l.getAttribute('href');
  16. break;
  17. }
  18. }
  19. }
  20. if (found) {
  21. prompt('Canonical URL:', found);
  22. } else {
  23. prompt('No declared canonical URL, here is the original:', url);
  24. }
  25. })();
Add Comment
Please, Sign In to add comment