Skip to content

Commit

Permalink
Move to v7.2.2(instead of v7.3), fix Trade Open Chat.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashank999 committed Jun 14, 2024
1 parent 12023b6 commit 86b51a2
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 48 deletions.
4 changes: 2 additions & 2 deletions extension/changelog.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[
{
"version": { "major": 7, "minor": 3, "build": 0 },
"version": { "major": 7, "minor": 2, "build": 2 },
"title": "Beta",
"date": false,
"logs": { "features": [], "fixes": [], "changes": [], "removed": [] }
"logs": { "features": [], "fixes": [{ "message": "Fixed Trade Open Chat.", "contributor": "TheFoxMan" }], "changes": [], "removed": [] }
},
{
"version": { "major": 7, "minor": 2, "build": 1 },
Expand Down
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "TornTools",
"version": "7.3.0",
"version": "7.2.2",
"description": "Several tools for Torn.",
"icons": { "16": "resources/images/icon_16.png", "48": "resources/images/icon_48.png", "128": "resources/images/icon_128.png" },
"action": { "default_title": "TornTools", "default_popup": "pages/popup/popup.html", "default_icon": "resources/images/icon_128.png" },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$("#editor-wrapper .editor-content.mce-content-body").keyup()
5 changes: 1 addition & 4 deletions extension/scripts/features/add-debug-info/ttAddDebugInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@

// Add the browser information to BBCode input.
// Need jQuery as dispatchEvent is not working.
executeScript(
(wrapped) => wrapped.$("#editor-wrapper .editor-content.mce-content-body").keyup(),
"$('#editor-wrapper .editor-content.mce-content-body').keyup();"
);
executeScript(chrome.runtime.getURL("scripts/features/add-debug-info/ttAddDebugInfo.inject.js"));
},
},
});
Expand Down
7 changes: 1 addition & 6 deletions extension/scripts/features/no-confirm/ttItemNoConfirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
function injectAdjustments() {
injectXHR();

document.head.appendChild(
document.newElement({
type: "script",
attributes: { type: "text/javascript", src: chrome.runtime.getURL("/scripts/features/no-confirm/ttItemNoConfirm.inject.js") },
})
);
executeScript(chrome.runtime.getURL("/scripts/features/no-confirm/ttItemNoConfirm.inject.js"), false);
}
})();
11 changes: 1 addition & 10 deletions extension/scripts/features/points-value/ttPointsValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,7 @@
);
});

// New method instead of executeScript() to avoid CSP error.
const scriptEl = document.newElement({
type: "script",
attributes: {
type: "text/javascript",
src: chrome.runtime.getURL("scripts/features/points-value/ttPointsValue.inject.js"),
},
});
document.head.appendChild(scriptEl);
setTimeout(() => scriptEl.remove(), 2000);
executeScript(chrome.runtime.getURL("scripts/features/points-value/ttPointsValue.inject.js"));
}

function removeValue() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(async () => {
const playerID = (await cookieStore.get("uid")).value;
const traderID = $(`#trade-container .log > li .desc a:not([href*="${playerID}"])`)
.attr("href")
.match(/XID=(\d*)/i)[1];

chat.r(traderID);
})();
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
class: "tt-open-chat",
});

button.addEventListener("click", () => executeScript((wrapped) => wrapped.chat.r(id), `chat.r(${id})`));
button.addEventListener("click", () => executeScript(chrome.runtime.getURL("scripts/features/trade-open-chat/ttTradeOpenChat.inject.js")));

document.find("#trade-container > .title-black").appendChild(
document.newElement({
Expand Down
25 changes: 13 additions & 12 deletions extension/scripts/global/functions/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,18 +429,19 @@ function showLoadingPlaceholder(element, show) {
}
}

function executeScript(handler, code) {
if (window.wrappedJSObject && handler) handler(window.wrappedJSObject);
else {
const script = document.newElement({
type: "script",
attributes: { type: "text/javascript" },
html: code,
});

document.head.appendChild(script);
setTimeout(() => script.remove(), 100);
}
function executeScript(filename, remove=true) {
const script = document.newElement({
type: "script",
attributes: {
type: "text/javascript",
src: filename,
}
});

document.head.appendChild(script);

if (remove)
setTimeout(() => script.remove(), 2000);
}

function updateQuery(key, value) {
Expand Down
14 changes: 2 additions & 12 deletions extension/scripts/global/functions/listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ let injectedXHR, injectedFetch;
function injectFetch() {
if (injectedFetch) return;

document.head.appendChild(
document.newElement({
type: "script",
attributes: { type: "text/javascript", src: chrome.runtime.getURL("/scripts/global/inject/fetch.inject.js") },
})
);
executeScript(chrome.runtime.getURL("/scripts/global/inject/fetch.inject.js"), false);
injectedFetch = true;
}

Expand All @@ -80,12 +75,7 @@ function addFetchListener(callback) {
function injectXHR() {
if (injectedXHR) return;

document.head.appendChild(
document.newElement({
type: "script",
attributes: { type: "text/javascript", src: chrome.runtime.getURL("/scripts/global/inject/xhr.inject.js") },
})
);
executeScript(chrome.runtime.getURL("/scripts/global/inject/xhr.inject.js"), false);
injectedXHR = true;
}

Expand Down

0 comments on commit 86b51a2

Please sign in to comment.