56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
// ==UserScript==
|
|
// @name Mealie compute
|
|
// @namespace https://mealie.ilnee.com/
|
|
// @include https://mealie.ilnee.com/
|
|
// @version 2025-12-02
|
|
// @description accumulate the weight of ingredients on mealie.ilnee.com
|
|
// @author me
|
|
// @match https://*.ilnee.com/*
|
|
// @require https://code.jquery.com/jquery-3.7.1.slim.min.js
|
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
|
|
// @grant none
|
|
// ==/UserScript==
|
|
window.onload = function() {
|
|
if (window.jQuery) {
|
|
console.log("jQuery loaded");
|
|
}
|
|
}
|
|
|
|
var sum;
|
|
|
|
function summyshizzle() {
|
|
sum = 0;
|
|
var h2 = $('h2:contains("Ingredients"):first');
|
|
|
|
var items = h2.parent().parent().find('div.v-list-item-title > div.ingredient-item > div.d-inline > p');
|
|
//var items = $('div.text-subtitle-1.dense-markdown.ingredient-item > div.d-inline > p');
|
|
var match;
|
|
var firstNumber = 0;
|
|
items.each(function(i, obj) {
|
|
//console.log(i);
|
|
//console.log(obj.innerHTML);
|
|
match = obj.innerHTML.match(/\d+/);
|
|
firstNumber = match ? parseInt(match[0], 10) : null;
|
|
//console.log(firstNumber);
|
|
sum += firstNumber;
|
|
console.log(sum);
|
|
|
|
});
|
|
|
|
return sum;
|
|
|
|
}
|
|
|
|
|
|
$(document)
|
|
.ready(function() {
|
|
$('body').on('click', 'button[large="false"][type="button"]', (function(e) {
|
|
sum = 0;
|
|
sum = summyshizzle();
|
|
// console.log('sum: ' + sum);
|
|
$('div.ilneesum').remove();
|
|
|
|
$(this).parent().parent().parent().parent().parent().after('<div class="ilneesum">' + sum + '</div>');
|
|
|
|
}));
|
|
}); |