Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active October 31, 2023 05:03
Show Gist options
  • Save pingyen/d0df43226dfc169046f999f6da0844a5 to your computer and use it in GitHub Desktop.
Save pingyen/d0df43226dfc169046f999f6da0844a5 to your computer and use it in GitHub Desktop.
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*
// @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