🏠 Home 

View Full Twitter Image

Undo Twitter's insistence to down-res images when viewing on its dedicated page and add a button to download the full image without the weird file extensions which don't count as actual images.

< Feedback on View Full Twitter Image

Review: OK - script works, but has bugs

§
Posted: 2019-05-01

New Twitter API is upon us, patch submitted here

Twitter is pushing a new API and picture requests have changed. As described in my fork there: https://greasyfork.org/en/scripts/382443-view-full-twitter-image

Feel free to merge or improve if you want to. Hope that helps!

Below is mostly what was added:

    let params = location.search;
if (params != "") { // "?" means we detected the new twitter API parameter format
if (!location.href.includes("name=orig")){
let vars = [], hash;
var baseurl = decodeURIComponent(window.location.href.slice(0, window.location.href.indexOf('?') + 1));
var hashes = decodeURIComponent(window.location.href.slice(window.location.href.indexOf('?') + 1 )).split('&');
// building parameter array
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
if ((hash[0] == 'name') && (hash[1] != 'orig')){
vars[hash[0]] = 'orig'; // enforces 'name' key
continue;
}
//vars.push(hash[0]); // probably not needed
vars[hash[0]] = hash[1];
}
// adding back parameters to the base url
var queryString = Object.keys(vars).map(key => key + '=' + vars[key]).join('&');
location.href = baseurl + queryString;
}
}
§
Posted: 2019-05-01

I have also changed the following line because it did not update / relocate to the updated URL anymore for some reason. (this line is not shown above, it's part of the old handler).

location.href.replace(":large", ":orig")

to

window.location.assign(location.href.replace(":large", ":orig"));
§
Posted: 2019-05-01

Thanks for informing me about the changes to the API, as well as submitting your diff. I'll look into updating the code based on your fork once I have time.

Post reply

Sign in to post a reply.