NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name +Moderator // @namespace https://plus.google.com/u/0/+LeeForestHimself // @version 0.2 // @description Currently a simple toggle-able moderator panel with Approve All and Remove All buttons for easier 'Likely Spam' moderation in Google+ Communities. // @author Lee Forest // @license MPL-2.0 // @match https://plus.google.com/u/0/communities/* // @match https://plus.google.com/communities/* // @run-at document-end // @grant GM_addStyle // ==/UserScript== // STYLES var styles = ` #pmod-reject-all { background: red; } #pmod-approve-all { background: green; } .pmod-panel-button { height: 30px; width: 90px; color: white; border-color: white; border-radius: 5px; } #pmod-panel { position: fixed; background: white; border: 3px inset #0f9d58; border-radius: 5px; width: 180px; left: calc(50% - 90px); top: 65px; z-index:100; } #pmod-main-button { position: fixed; background: white; color: green; font-size: 12px; font-weight: bold; border-color: white; border-size: 2px; right: 0px; top: 0px; height:30px width:80px; z-index:100; }`; GM_addStyle(styles); // HELPER FUNCTIONS function getXpathElem(path) { return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } // REJECT ALL BUTTON function rejectAll() { var rejectButtons = document.querySelectorAll('div[role="button"][data-tooltip="Remove"]'); for (var i in rejectButtons) { if (rejectButtons[i].click) { rejectButtons[i].click() } } } var rejectAllBut = document.createElement("button"); rejectAllBut.appendChild(document.createTextNode("Reject All")); rejectAllBut.setAttribute("id", "pmod-reject-all"); rejectAllBut.setAttribute("class", "pmod-panel-button"); rejectAllBut.onclick = function () { rejectAll(); } // APPROVE ALL BUTTON function approveAll() { var approveButtons = document.querySelectorAll('div[role="button"][data-tooltip="Approve"]'); for (var i in approveButtons) { if(approveButtons[i].click) { approveButtons[i].click() } } } var approveAllBut = document.createElement("button"); approveAllBut.appendChild(document.createTextNode("Approve All")); approveAllBut.setAttribute("id", "pmod-approve-all"); approveAllBut.setAttribute("class", "pmod-panel-button"); approveAllBut.onclick = function () { approveAll(); } // MAIN PANEL var mainPanel = document.createElement("div"); mainPanel.setAttribute("id", "pmod-panel"); mainPanel.appendChild(approveAllBut); mainPanel.appendChild(rejectAllBut); function togglePanel() { console.log("toggling panel"); var panel = document.getElementById("pmod-panel"); if (panel) { panel.parentNode.removeChild(panel); } else { document.getElementsByTagName("html")[0].appendChild(mainPanel); } } function addPmodButton () { var btn = document.createElement("button"); btn.setAttribute("id", "pmod-main-button"); btn.appendChild(document.createTextNode("+Moderator")); btn.onclick = function () { console.log("button clicked!"); togglePanel(); } document.getElementsByTagName("html")[0].appendChild(btn); } // SCRIPT MAIN (function() { 'use strict'; addPmodButton(); })();