// ==UserScript==
// @name ItzaGud.net improvements
// @name:de ItzaGud.net Verbesserungen
// @namespace https://kurotaku.de
// @version 0.7.1
// @description Some improvements for ItzaGud.net, all of them can be disabled in the config (Topbar | Bottom of mobile navbar)
// @description:de Einige Verbesserungen für ItzaGud.net, die alle in der Konfiguration deaktiviert werden können (Topbar | Unten in der Mobilen Navigationsleiste)
// @author Kurotaku
// @license CC BY-NC-SA 4.0
// @match https://itzagud.net/*
// @icon https://i0.wp.com/itzagud.net/wp-content/uploads/2022/12/cropped-512logo.png
// @updateURL https://raw.githubusercontent.com/Kurotaku-sama/Userscripts/main/userscripts/ItzaGud_improvements/script.user.js
// @downloadURL https://raw.githubusercontent.com/Kurotaku-sama/Userscripts/main/userscripts/ItzaGud_improvements/script.user.js
// @require https://raw.githubusercontent.com/Kurotaku-sama/Userscripts/main/libraries/kuros_library.js
// @require https://cdn.jsdelivr.net/npm/sweetalert2
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// ==/UserScript==
let daily_missions = []; // List with daily missions
let weekly_missions = []; // List with weekly missions
let one_time_missions = []; // List with one time missions
(async function() {
await init_gm_config();
insert_gm_config_button(); // Add the button to the filter container to open the configuration menu
if(GM_config.get("script_enabled")) {
// Shows instead GudCoinz the $ Value
if(GM_config.get("enabled_convert_gudcoinz"))
convert_gudcoinz();
// Comments are collapsed by default with a button
if(GM_config.get("enabled_collapsible_comments"))
collapsible_comments();
// 3 Buttons to do dailys, weekly and one time missions at once
if(GM_config.get("enabled_open_all_missions"))
open_all_missions();
// Daily video rewards enable controlls and autoplay
if(GM_config.get("enabled_daily_videos_controls_autoplay"))
daily_videos_controls_autoplay();
}
})();
async function init_gm_config() {
const config_id = "configuration_ignetimp";
await migrate_config_id(config_id);
GM_registerMenuCommand("Settings", () => GM_config.open());
GM_config.init({
id: config_id,
title: 'ItzaGud.net improvements config',
fields: {
script_enabled: {
type: 'checkbox',
default: true,
label: 'Enable/Disable the script',
},
enabled_convert_gudcoinz: {
type: 'checkbox',
default: true,
label: 'Use point conversion',
},
enabled_collapsible_comments: {
type: 'checkbox',
default: true,
label: 'Collapsed comments + comment box is on top of comment section',
},
enabled_open_all_missions: {
type: 'checkbox',
default: false,
label: '[Currently useless due to new timewall]
Buttons on the mission page, that allows you to open all at once from a section (Daily, Weekly, One Time Missions)',
},
enabled_daily_videos_controls_autoplay: {
type: 'checkbox',
default: true,
label: '[Currently useless due to new timewall]
Videomissions start automatic when opened, controls are enabled and video is muted',
},
gudcoinz_conversion: {
type: 'int',
default: 2500,
label: 'Value of gudcoinz that are worth $0.01',
},
},
events: {
save: () => { location.reload() },
},
frame: create_configuration_container(),
});
await wait_for_gm_config();
}
function insert_gm_config_button() {
let headerbar = document.querySelector(".header-top .header-right");
let button = "itzagud improvement config";
headerbar.insertAdjacentHTML('afterbegin', button);
document.querySelector("#gm_config_button").addEventListener("click",() => GM_config.open());
// Mobile
let mobilenavigation = document.querySelector("#menu-wd-header-navigation");
let mobilebutton = "itzagud improvement config";
mobilenavigation.insertAdjacentHTML('afterend', mobilebutton);
document.querySelector("#gm_config_button_mobile").addEventListener("click",() => GM_config.open());
}
function convert_gudcoinz() {
// Get the 2 elements for value and label of wallet
let el_value = document.querySelector(".gamipress-inline-points-wrapper .gamipress-inline-points-amount");
let el_label = document.querySelector(".gamipress-inline-points-wrapper .gamipress-inline-points-label");
if(el_value && el_label) { // Check if they exist
// Calculation
let value = el_value.innerHTML.replace(',', '');
let rest = value%GM_config.get("gudcoinz_conversion");
let value_dollars = (value-rest)/GM_config.get("gudcoinz_conversion")/100;
// Output
el_value.innerHTML = `You have: $${value_dollars.toFixed(2)}`; // Output value with 2 decimals
// If you don't care about how much GudCoinz you have comment this out and in the line underneath remove the //
el_label.innerHTML = `
${rest}/${GM_config.get("gudcoinz_conversion")}`;
// el_label.innerHTML = ``;
// Fix for collapsing points when clicking on cart
if(document.querySelector("#gamipress_user_points_widget-5"))
document.querySelector("#gamipress_user_points_widget-5").removeAttribute("class");
}
}
// function rename_gudcoinz_menuitem() {
// document.querySelectorAll(".menu-item-17319 > a").forEach(el => el.innerHTML = `Earn GudCoinz`); // Just rename the text of this menu item
// }
function collapsible_comments() {
if(document.querySelector(".commentlist")) { // Only if a commentlist was found
// Hide reviews (will be enabled through button)
// Put comments/reviews on top of review bar
GM_addStyle(`
#reviews {
display : grid;
}
#reviews > #review_form_wrapper {
order: -1;
}
.commentlist {
display: none;
}
`);
// Add button above the comment list
let button = ``;
document.querySelector(".commentlist").insertAdjacentHTML('beforebegin', button);
// firstclick is required since the style for diplay : none is not on the element itself
let first_click = false;
document.querySelector("#expand_comments_button").addEventListener("click", function () {
let button = document.querySelector("#expand_comments_button");
let cl = document.querySelector(".commentlist");
if (cl.style.display === "none" || !first_click) { // Show the comments and change button text
cl.style.display = "block";
button.innerHTML = "Hide comments";
first_click = true;
} else { // Hide the comments and change button text
cl.style.display = "none";
button.innerHTML = "Show comments";
}
});
}
}
function open_all_missions() {
if(document.querySelector(".post-230")) { // Only if you are on missions page
// Fill the arrays with the missions
fill_array_missions();
// Creating container and buttons
let missionbutton_container = `