Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active November 16, 2022 18:48
Embed
What would you like to do?
P_Vexed Sharer
// ==UserScript==
// @name P_Vexed Sharer
// @namespace https://www.facebook.com/groups/p.vexed
// @version 0.1
// @description Facebook Sharer + P_Vexed
// @author You
// @match https://www.facebook.com/sharer/sharer.php?app_id=123561918055313&u=*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(async function() {
'use strict';
const waitForSelector = selector => new Promise(resolve => {
const timer = setInterval(() => {
const element = document.querySelector(selector);
if (element === null) {
return;
}
clearInterval(timer);
resolve(element);
}, 100);
});
(await waitForSelector('[audience="self"]')).click();
(await waitForSelector('[audience="group"]')).click();
const input = await waitForSelector('#audience_group');
input.click();
document.execCommand('InsertText', false, 'P_Vexed');
input.dispatchEvent(new FocusEvent('focusin', { bubbles: true }));
(await waitForSelector('[id="587289954686277"]')).dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
setTimeout(() => {
document.getElementById('platformDialogForm').submit();
}, 200);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment