Last active
August 1, 2019 08:14
-
-
Save davidmz/1238089 to your computer and use it in GitHub Desktop.
[Букмарклет для перехода из альбома в G+ к альбому в Picasa] Нажимать надо, находясь на страница альбома G+. #bookmarklet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Собственно букмарклет: | |
* | |
javascript:(function(){var b=window.location,a;if(b.host=="plus.google.com"&&(a=b.pathname.match(/\/photos\/(\d+)\/albums\/(\d+)$/))){var b=a[1],c=a[2];console.log(c);a=new XMLHttpRequest;a.open("GET","https://plus.google.com/u/0/_/photos/albums/"+b);a.responseType="text";a.onload=function(){for(var a=JSON.parse(this.response.replace(")]}'","").replace(/\[,/g,'["",').replace(/,,/g,',"",').replace(/,,/g,',"",')),b=0;b<a[2].length;b++)if(a[2][b][5]==c){window.location=a[2][b][8];return}alert("Album not found")}; | |
a.send()}else alert("Invalid page address")})(); | |
* | |
* Ниже приведён несжатый код | |
*/ | |
(function() { | |
var loc = window.location, m; | |
if (loc.host == "plus.google.com" && (m = loc.pathname.match(/\/photos\/(\d+)\/albums\/(\d+)$/))) { | |
var userId = m[1]; | |
var albumId = m[2]; | |
console.log(albumId); | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", "https://plus.google.com/u/0/_/photos/albums/" + userId); | |
xhr.responseType = "text"; | |
xhr.onload = function() { | |
var resp = JSON.parse(this.response.replace(")]}'", "").replace(/\[,/g, '["",').replace(/,,/g, ',"",').replace(/,,/g, ',"",')); | |
for (var i = 0; i < resp[2].length; i++) { | |
if (resp[2][i][5] == albumId) { | |
window.location = resp[2][i][8]; | |
return; | |
} | |
} | |
alert("Album not found"); | |
}; | |
xhr.send(); | |
} else { | |
alert("Invalid page address"); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment