0% found this document useful (0 votes)
119 views2 pages

Add job level to phone tool(1)

This document is a userscript designed to enhance the phone tool by adding the job level of users on specific Amazon web pages. It fetches user data from the phone tool API and displays the job level in the user details table. The script includes error handling to manage potential issues during execution.

Uploaded by

avsidra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views2 pages

Add job level to phone tool(1)

This document is a userscript designed to enhance the phone tool by adding the job level of users on specific Amazon web pages. It fetches user data from the phone tool API and displays the job level in the user details table. The script includes error handling to manage potential issues during execution.

Uploaded by

avsidra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// ==UserScript==

// @name Add job level to phone tool


// @downloadURL https://improvement-ninjas.amazon.com/GreaseMonkey/jobdata.user.js
// @updateURL https://improvement-ninjas.amazon.com/GreaseMonkey/jobdata.user.js
// @namespace http://amazon.com
// @description Adds job level to phone tool
// @include https://connect.amazon.com/people/*
// @include https://connect.amazon.com/users/*
// @include https://phonetool.amazon.com/people/*
// @include https://phonetool.amazon.com/users/*
// @exclude https://phonetool.amazon.com/users/*.json
// @exclude https://phonetool.amazon.com/users/*/org
// @exclude https://phonetool.amazon.com/users/*/communities
// @exclude https://phonetool.amazon.com/bookmark*
// @grant GM.info
// @version 21
// ==/UserScript==

/* jshint esversion: 11 */
/* globals GM */

(async function() {

"use strict";

function getPersonalInfoRowDiv(level)
{
let keyDiv = document.createElement("div");
keyDiv.classList.add("TableProperty");
keyDiv.innerText = "LEVEL:";

let valueDiv = document.createElement("div");


valueDiv.classList.add("TableValue");
valueDiv.innerText = level;

let wrapper = document.createElement("div");


wrapper.classList.add("TableRow");
wrapper.appendChild(keyDiv);
wrapper.appendChild(valueDiv);

return wrapper;
}

let login;

try {
let userReactData = JSON.parse(document.querySelector("div[data-react-
class=UserDetails]").dataset["reactProps"]);
login = userReactData.targetUser.targetUserLogin;

if (!login)
throw new Error("Failed to find user login");

let payload = await fetch(`https://phonetool.amazon.com/users/${login}.json`)


.then(resp => resp.json());

let container = document.querySelector(".UserDetailsTable");


if (!container)
throw new Error("Failed to find user details table");

let newdiv = getPersonalInfoRowDiv(payload.job_level);


container.appendChild(newdiv);
}

catch (e) {
console.error(`'${GM.info.script.name}': Greasemonkey script probably needs to
be updated`, e);
return;
}

})();

You might also like