Created
March 1, 2025 09:01
-
-
Save skeptrunedev/318790eee01d7abf6418c62623255dc7 to your computer and use it in GitHub Desktop.
true-classic-trieve-tampermonkey-script.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name True Classic | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-03-01 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match https://www.trueclassictees.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=trueclassictees.com | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const style = document.createElement('style'); | |
| style.textContent = ` | |
| #trieve-inline-search-modal-container { | |
| max-width: 90rem; | |
| margin-left: auto; | |
| margin-right: auto; | |
| margin-top: 2rem; | |
| margin-bottom: 2rem; | |
| padding: .625rem calc(var(--edge-space) - .625rem) 0 var(--edge-space); | |
| } | |
| `; | |
| document.head.appendChild(style); | |
| const link = document.createElement("link"); | |
| link.rel = "stylesheet"; | |
| link.href = "https://search-component.trieve.ai/dist/index.css"; | |
| document.head.appendChild(link); | |
| import("https://search-component.trieve.ai/dist/vanilla/index.js") | |
| .then((module) => { | |
| const root = document.createElement("div"); | |
| root.classList.add("trigger"); | |
| document.body.appendChild(root); | |
| module.renderToDiv(root, { | |
| apiKey: "tr-zcmgd0AGM1X3kY9PouwBy3IJ1wP9WwsY", | |
| datasetId: "33f7a721-86da-4b9a-916b-6b1bb2e81b67", | |
| baseUrl: "https://api.trieve.ai", | |
| type: "ecommerce", | |
| analytics: true, | |
| tags: [{"description":"only set this to true if the user is talking about shorts","iconClassName":"fh-solid fa-bucket","label":"shorts","selected":null,"tag":"bottoms"},{"description":"only set this to true if the user is talking about shorts","iconClassName":"fh-solid fa-bucket","label":"Shorts","selected":null,"tag":"bottom"},{"description":"product is a collection bundled set of other products","iconClassName":"fh-solid fa-bucket","label":"Pack","selected":null,"tag":"Pack"},{"description":"pants or trousers or chinos or slacks","iconClassName":"fh-solid fa-bucket","label":"Trouser","selected":null,"tag":"Trouser"},{"description":"pants or trousers or chinos or slacks","iconClassName":"fh-solid fa-bucket","label":"Pants","selected":null,"tag":"Pants"},{"description":"product is on sale","iconClassName":"fh-solid fa-bucket","label":"Sale","selected":null,"tag":"Sale"},{"description":"pants are chinos","iconClassName":"fh-solid fa-bucket","label":"Chino","selected":null,"tag":"Chino"},{"description":"pants or trousers or chinos or slacks","iconClassName":"fh-solid","label":"Pant","selected":null,"tag":"Pant"}], | |
| brandLogoImgSrcUrl: "https://www.trueclassictees.com/cdn/shop/t/645/assets/favicon.png?v=34746499990368564261692589778", | |
| brandName: "True Classic", | |
| brandColor: "#0c0a08", | |
| placeholder: "How can I help?", | |
| defaultAiQuestions: ["Why do True Classics fit so well?", "Pants for 5' 8\" 235 pounds", "clothes for work", "surprise me!", "black pants for Harley riders"], | |
| defaultSearchMode: "chat", | |
| useGroupSearch: true, | |
| showFloatingSearchIcon: "true", | |
| }); | |
| // get the id of the product along with its variants (AKA chunk_group in Trieve) from the URL | |
| const groupTrackingId = window.inveterate.properties.page.product.id.toString(); | |
| // get the element you want to put the inline search component above | |
| const inlineAttach = document.querySelector( | |
| ".pdp-accord" | |
| ); | |
| if (!inlineAttach) { | |
| return; | |
| } | |
| const inlineRoot = document.createElement("div"); | |
| inlineRoot.id = "trieve-inline-search-modal-container"; | |
| inlineAttach.insertBefore(inlineRoot, inlineAttach.firstChild); | |
| module.renderToDiv(inlineRoot, { | |
| inline: true, | |
| groupTrackingId, | |
| apiKey: "tr-zcmgd0AGM1X3kY9PouwBy3IJ1wP9WwsY", | |
| datasetId: "33f7a721-86da-4b9a-916b-6b1bb2e81b67", | |
| baseUrl: "https://api.trieve.ai", | |
| type: "ecommerce", | |
| analytics: true, | |
| tags: [{"description":"only set this to true if the user is talking about shorts","iconClassName":"fh-solid fa-bucket","label":"shorts","selected":null,"tag":"bottoms"},{"description":"only set this to true if the user is talking about shorts","iconClassName":"fh-solid fa-bucket","label":"Shorts","selected":null,"tag":"bottom"},{"description":"product is a collection bundled set of other products","iconClassName":"fh-solid fa-bucket","label":"Pack","selected":null,"tag":"Pack"},{"description":"pants or trousers or chinos or slacks","iconClassName":"fh-solid fa-bucket","label":"Trouser","selected":null,"tag":"Trouser"},{"description":"pants or trousers or chinos or slacks","iconClassName":"fh-solid fa-bucket","label":"Pants","selected":null,"tag":"Pants"},{"description":"product is on sale","iconClassName":"fh-solid fa-bucket","label":"Sale","selected":null,"tag":"Sale"},{"description":"pants are chinos","iconClassName":"fh-solid fa-bucket","label":"Chino","selected":null,"tag":"Chino"},{"description":"pants or trousers or chinos or slacks","iconClassName":"fh-solid","label":"Pant","selected":null,"tag":"Pant"}], | |
| brandLogoImgSrcUrl: "https://www.trueclassictees.com/cdn/shop/t/645/assets/favicon.png?v=34746499990368564261692589778", | |
| brandName: "True Classic", | |
| brandColor: "#0c0a08", | |
| placeholder: "How can I help?", | |
| defaultSearchMode: "chat", | |
| useGroupSearch: true, | |
| showFloatingSearchIcon: "true", | |
| }); | |
| }) | |
| .catch((error) => { | |
| console.error("Failed to load search comonent:", error); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment