BTW, I wrote the script to run a context command because you said you want to use the masstagger plugin to update tags, but you don't actually need an extra plugin for that (nor masstagger, neither quicktag). This version of the script updates tags by code. I commented out the lines I replaced for you to see the changes. As the previous version, this one writes the value 5 in the rating field for liked tracks.
"use strict";
include(fb.ComponentPath + "//docs//Helpers.js");
include(fb.ComponentPath + "//docs//Flags.js");
let likeButton = new LikeButton();
function on_paint(gr){
likeButton.paint(gr);
}
function on_mouse_move(x, y){
likeButton.mouse_move(x, y);
}
function on_mouse_leave(){
likeButton.mouse_leave();
}
function on_mouse_lbtn_up(){
likeButton.mouse_lbtn_up();
}
function on_metadb_changed(){
window.Repaint();
}
function on_selection_changed(){
window.Repaint();
}
function LikeButton(){
this.font = gdi.Font(window.GetProperty("FONT", "segoe UI"), window.GetProperty("FONT_SIZE", 48));
this.label = String.fromCharCode(9829);
this.paint = (gr) => {
this.forecolour = this.active?colours.Red:colours.Gray;
gr.GdiDrawText(this.label, this.font, this.forecolour, 0, 0, window.Width, window.Height, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
if (this.mouseover && (this.target.Count > 0)) gr.FillSolidRect(0, 0, window.Width, window.Height, setAlpha(colours.Gray, 60));
}
this.mouse_move = (x, y) => {
if (!this.mouseover){
this.mouseover = true;
window.Repaint();
}
}
this.mouse_leave = () => {
this.mouseover = false;
window.Repaint();
}
this.mouse_lbtn_up = () => {
// fb.RunContextCommandWithMetadb(this.command, this.target);
this.updateTags();
}
this.mouseover = false;
}
Object.defineProperty(LikeButton.prototype, "target", {get: () => fb.GetSelections()})
Object.defineProperty(LikeButton.prototype, "active", {get: function(){return Math.min(...fb.TitleFormat("%rating%").EvalWithMetadbs(this.target)) == 5}})
//Object.defineProperty(LikeButton.prototype, "command", {get: function(){return "Tagging/Quick Tagger/Set <rating> to/" + (this.active?"[Remove Field]":"5")}});
Object.defineProperty(LikeButton.prototype, "updateTags", {value: function(){
let arr = [];
for (let i = 0; i < this.target.Count; ++i) {arr.push({"rating" : this.active?"":5})};
this.target.UpdateFileInfoFromJSON(JSON.stringify(arr));
}
})
Mind that it can target multiple tracks. When you select more than one track, it will behave as if the tracks were all unliked if at least one of them is, that means the icon will be painted gray and clicking on it will like all the selected tracks.