Skip to content

Commit

Permalink
Added link to recommendations.
Browse files Browse the repository at this point in the history
Added new products hooks for plugins.
  • Loading branch information
FMaz008 committed Nov 3, 2024
1 parent f42d4e7 commit a4a5018
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
15 changes: 15 additions & 0 deletions scripts/bootloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async function init() {

displayAccountData();
initAddNotificationMonitorLink();
addRecommendationLink();
showGDPRPopup();
await initFlushTplCache(); //And display the version changelog popup
initInjectScript();
Expand Down Expand Up @@ -237,6 +238,20 @@ function initAddNotificationMonitorLink() {
li.appendChild(a);
}
}

function addRecommendationLink(){
const tab = document.querySelector(".a-tab-container > ul > li:last-of-type");
if (tab) {
const rec = tab.cloneNode(true);
rec.style.float = "right";
const a = rec.firstChild;
a.rel = "noreferrer";
a.href = "/gp/yourstore/iyr/";
a.textContent = "Recommendations";
tab.parentNode.appendChild(rec);
}
}

async function initCreateTabs() {
//Create the Discard grid
showRuntime("BOOT: Creating tabs system");
Expand Down
1 change: 0 additions & 1 deletion scripts/preboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ function hookBind(hookname, func) {
if (arrBinding == undefined) arrBinding = [];
arrBinding.push(func);
mapHook.set(hookname, arrBinding);
console.log(mapHook);
}
function hookExecute(hookname, variables) {
let arrBinding = mapHook.get(hookname);
Expand Down
23 changes: 17 additions & 6 deletions scripts/vh_service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ const transformIsHighlight = myStream.transformer(function (data) {
const highlightKWMatch = keywordMatch(Settings.get("general.highlightKeywords"), data.title);
data.KWsMatch = highlightKWMatch!==false;
data.KW = highlightKWMatch;
if(highlightKWMatch!==false){
let data2 = { ...data };
data2.type = "hookExecute";
data2.hookname = "newItemKWMatch";
sendMessageToAllTabs(data2, "newItemKWMatch");
}

return data;
});
const transformSearchPhrase = myStream.transformer(function (data) {
Expand Down Expand Up @@ -69,12 +64,28 @@ const transformPostNotification = myStream.transformer(function (data) {
}
return data;
});
const transformExecuteHooks = myStream.transformer(function (data) {
let data2 = { ...data };

if(data.KWsMatch){
data2.type = "hookExecute";
data2.hookname = "newItemKWMatch";
sendMessageToAllTabs(data2, "newItemKWMatch");
}else{
data2.type = "hookExecute";
data2.hookname = "newItemNoKWMatch";
sendMessageToAllTabs(data2, "newItemNoKWMatch");
}

return data;
});
myStream
.pipe(filterHideitem)
.pipe(transformIsHighlight)
.pipe(transformSearchPhrase)
.pipe(transformUnixTimestamp)
.pipe(transformPostNotification)
.pipe(transformExecuteHooks)
.output((data) => {
//Broadcast the notification
sendMessageToAllTabs(data, "notification");
Expand Down

0 comments on commit a4a5018

Please sign in to comment.