Browse Source

Added code to modify the "add x" buttons on load

main
Steven 1 year ago
commit
ec8e262c54
  1. 170
      HandleAddButtons.js
  2. 5
      README.md

170
HandleAddButtons.js

@ -0,0 +1,170 @@
// ==UserScript==
// @name PodioTweaker-HideAddButtons
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Make tweaks to podio to help ensure a pit of success
// @author Steven Allen
// @match https://podio.com/qhreicom/qlty-crm/apps/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=podio.com
// @grant none
// ==/UserScript==
// @dont_require https://code.jquery.com/jquery-3.7.1.min.js
'use strict';
////////
////////////// BEGIN COPIED CODE FROM @require https://cdn.jsdelivr.net/gh/CoeJoder/waitForKeyElements.js@v1.2/waitForKeyElements.js
//https://github.com/CoeJoder/waitForKeyElements.js
/**
* A utility function for userscripts that detects and handles AJAXed content.
*
* Usage example:
*
* function callback(domElement) {
* domElement.innerHTML = "This text inserted by waitForKeyElements().";
* }
*
* waitForKeyElements("div.comments", callback);
* // or
* waitForKeyElements(selectorFunction, callback);
*
* @param {(string|function)} selectorOrFunction - The selector string or function.
* @param {function} callback - The callback function; takes a single DOM element as parameter.
* If returns true, element will be processed again on subsequent iterations.
* @param {boolean} [waitOnce=true] - Whether to stop after the first elements are found.
* @param {number} [interval=300] - The time (ms) to wait between iterations.
* @param {number} [maxIntervals=-1] - The max number of intervals to run (negative number for unlimited).
*/
function waitForKeyElements(selectorOrFunction, callback, waitOnce, interval, maxIntervals) {
if (typeof waitOnce === "undefined") {
waitOnce = true;
}
if (typeof interval === "undefined") {
interval = 300;
}
if (typeof maxIntervals === "undefined") {
maxIntervals = -1;
}
var targetNodes = (typeof selectorOrFunction === "function")
? selectorOrFunction()
: document.querySelectorAll(selectorOrFunction);
var targetsFound = targetNodes && targetNodes.length > 0;
if (targetsFound) {
targetNodes.forEach(function(targetNode) {
var attrAlreadyFound = "data-userscript-alreadyFound";
var alreadyFound = targetNode.getAttribute(attrAlreadyFound) || false;
if (!alreadyFound) {
var cancelFound = callback(targetNode);
if (cancelFound) {
targetsFound = false;
}
else {
targetNode.setAttribute(attrAlreadyFound, true);
}
}
});
}
if (maxIntervals !== 0 && !(targetsFound && waitOnce)) {
maxIntervals -= 1;
setTimeout(function() {
waitForKeyElements(selectorOrFunction, callback, waitOnce, interval, maxIntervals);
}, interval);
}
}
////////////// END OF COPIED CODE
function getNewDestination(pathName) {
console.log("pathname: "+ pathName);
switch (pathName) {
//💫 Use a differnt form
case "/qhreicom/qlty-crm/apps/external-leads":
case "/qhreicom/qlty-crm/apps/seller-leads":
return "https://podio.com/webforms/29098562/2368311";
case "/qhreicom/qlty-crm/apps/sales-offers":
return "https://podio.com/webforms/29098535/2368294";
case "/qhreicom/qlty-crm/apps/cash-buyers":
return "https://podio.com/webforms/29098542/2368298";
case "/qhreicom/qlty-crm/apps/wholesalers":
return "https://podio.com/webforms/29098543/2368299";
//✨Allow people to use
case "/qhreicom/qlty-crm/apps/marketing-numbers":
case "/qhreicom/qlty-crm/apps/team-members":
case "/qhreicom/qlty-crm/apps/major-markets": //Used as list option for Cash Buyers app
case "/qhreicom/qlty-crm/apps/sops":
case "/qhreicom/qlty-crm/apps/lead-sources":
return "";
//⛔Dont let people add
case "/qlty-crm/apps/need-to-sell-fast":
case "/qhreicom/qlty-crm/apps/sales":
case "/qhreicom/qlty-crm/apps/smrtphone-logs":
case "/qhreicom/qlty-crm/apps/lists":
case "/qhreicom/qlty-crm/apps/member-s":
case "/qhreicom/qlty-crm/apps/comm-queue": //?
case "/qhreicom/qlty-crm/apps/kpis-track"://?
case "/qlty-crm/apps/drip-numbers"://?
case "/qhreicom/qlty-crm/apps/sales-log"://?
return "#";
//⚠Unsure if we should be using this yet
case "/qhreicom/qlty-crm/apps/campaigns": //?
case "/qhreicom/qlty-crm/apps/marketing-kpis": //?
case "/qhreicom/qlty-crm/apps/settings": //Editing the one extent is ok but not sure if add is allowed
case "/qhreicom/qlty-crm/apps/feed": //?
case "/qhreicom/qlty-crm/apps/drip-msgs": //Editing is ok not sure if add should be allowed
case "/qhreicom/qlty-crm/apps/title-companies": //Does a form exist or should we use this?
case "/qhreicom/qlty-crm/apps/lead-followups": //?
return null;
default: //Un-reviewed Url's
return null;
}
return null;
}
function fixButton(targetButton){
console.log("found targetButton: "+ targetButton);
//var targetButton = document.getElementById("featureTourOnboarding");
var originalText = targetButton.innerText;
//replace targets url with the correct url to use
var newDestination =getNewDestination(window.location.pathname);
if(newDestination === null) {
console.log("Has not been reviewed yet");
targetButton.innerHTML = "⚠"+originalText +"⚠";
return;
} else if(newDestination === "") {
console.log("Ok to use this button");
targetButton.innerHTML = "✨"+originalText +"✨";
return;
} else if(newDestination === "#") {
console.log("Changed Button Functionality");
console.log("Dont use this button");
targetButton.innerHTML = "⛔<s>"+originalText +"</s>⛔";
} else {
console.log("Changed Button Functionality");
targetButton.innerHTML = "💫"+originalText +"💫";
}
targetButton.href = getNewDestination(window.location.pathname);
targetButton.removeAttribute('onclick');
targetButton.addEventListener('click', () => {
window.location.assign(targetButton.href);
});
}
/*
(new MutationObserver(check)).observe(document, {childList: true, subtree: true});
function check(changes, observer) {
if(document.querySelector('#mySelector')) {
observer.disconnect();
// actions to perform after #mySelector is found
}
}
*/
waitForKeyElements('.button-new.add-item.primary.baby-button', fixButton,false,300,-1);

5
README.md

@ -0,0 +1,5 @@
# PodioTweaker
This app is to be used inside tampermonkey
The script exists to help ensure a pit of success so people dont click things they should not inside our podio app.
Loading…
Cancel
Save