Created
July 1, 2015 22:09
-
-
Save Terrance/1033ab2b3ccb80d9278f to your computer and use it in GitHub Desktop.
A snippet for bulk converting Facebook privacy modes on all currently visible posts in Activity Log.
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
| // Mode to find, and mode to switch to, as shown in the privacy dropdown. | |
| var from = "Public", to = "Friends"; | |
| // Gather all posts on the old mode. | |
| var posts = $$('a[aria-label="' + from + '"]'); | |
| // Assuming running from the console, copy the $$ selector method. | |
| window.$$_ = $$; | |
| // Facebook overrides setTimeout, so need to obtain one from elsewhere. | |
| // Don't destroy the frame, otherwise it'll stop working. | |
| var f = document.createElement("iframe"); | |
| f.style.display = "none"; | |
| document.documentElement.appendChild(f); | |
| window.setTimeout_ = f.contentWindow.setTimeout; | |
| // First pass: preload all the menus (will hang the page). | |
| for (var i in posts) { | |
| if (typeof posts[i].click === "function") posts[i].click(); | |
| } | |
| // Second pass: open each menu in turn, select the new privacy option. | |
| function proc(i) { | |
| posts[i].click(); | |
| // Wait a moment... (using the stolen timeout method) | |
| setTimeout_(function() { | |
| // Now find and click the desired mode. | |
| $$_('li[data-label="' + to + '"] a', posts[i].nextSibling)[0].click(); | |
| setTimeout(function() { | |
| proc(i + 1); | |
| }, 100); | |
| }, (i === 0 ? 500 : 100)); | |
| } | |
| proc(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment