hckr / fb-post-screenshot

Firefox Web Extension to save Facebook posts as images
https://hckr.pl/fb-post-screenshot/
Mozilla Public License 2.0
20 stars 7 forks source link

Update for new Facebook layout 2020 #33

Closed JZersche closed 3 years ago

colorimeter commented 3 years ago

@hckr if everything is fine with this PR, could you merge it in order to make your plugin work again on the new layout?

hckr commented 3 years ago

@colorimeter AFAIR it's not finished. I'll check it in the evening and try to release a working version. Haven't had much time lately, sorry 😅

hckr commented 3 years ago

Unfortunately, as I thought, this code doesn't work as well as mine older version. It probably worked at the time it was written, but it was too tightly coupled to Facebook's code.

It takes a lot of time to adapt to Facebook changes, it also doesn't help they do many things to make parsing the site as painful as possible – for example the post permalink is being set only after one hovers on the link (it's the first issue I'm yet to solve). I'll probably check how other Facebook add-ons solved this, if any.

In conclusion, I'll try to make the add-on work, but it's not my priority and might take some time.

JZersche commented 3 years ago

Unfortunately, as I thought, this code doesn't work as well as mine older version. It probably worked at the time it was written, but it was too tightly coupled to Facebook's code.

It takes a lot of time to adapt to Facebook changes, it also doesn't help they do many things to make parsing the site as painful as possible – for example the post permalink is being set only after one hovers on the link (it's the first issue I'm yet to solve). I'll probably check how other Facebook add-ons solved this, if any.

In conclusion, I'll try to make the add-on work, but it's not my priority and might take some time.

        for (let i = 0; i < nodes.length; i++) {
            var NODE = nodes[i];
            if(NODE.textContent.match(/(posts|photos)/)){
                try{
                    let event = new MouseEvent('mouseover',{bubbles:true})
                    let event2 = new MouseEvent('mouseout',{bubbles:true})
                    NODE.dispatchEvent(event);

NODE.dispatchEvent(event);NODE.dispatchEvent(event2);

You can dispatch hover events to get it to work. I have a fully working script which takes screenshots, would you like to review it? If you can make a better version, I would encourage you to try before I send my full source code. If you want to deal with the post permalinks, you can use this: https://greasyfork.org/en/scripts/424272-facebook-show-timestamps-on-posts

Look at my method for getting the timestamps to show up, and I used the same method to display the post permalinks.

Currently, the script below requires the timestamps to be inserted before the url script will work, and you have to press f5 on your wall page in order for everything to load. Sometimes when you make new posts, you'll have to wait about 5 minutes for Facebook's servers to get the data sets correct, but the times are accurate for the most part. This script was complicated to write and without knowledge of XHR and how AJAX works on Facebook doing it this way is the only way I can suggest. It works flawlessly if you open each post on it's own page, so the times are always correct.

greasyfork.org/en/scripts/424339-facebook-show-urls-on-posts

JZersche commented 3 years ago

image

It will be available via my Gumroad, anyone who wants it. Can find it here, https://gumroad.com/l/dSEvQ

By default this will generate an .html and a .png image.