Skip to content

Instantly share code, notes, and snippets.

@GameTec-live
Last active April 24, 2024 16:27
Show Gist options
  • Save GameTec-live/0d5fe22a97cf989010aa9957a31b3348 to your computer and use it in GitHub Desktop.
Save GameTec-live/0d5fe22a97cf989010aa9957a31b3348 to your computer and use it in GitHub Desktop.
A git patch to remove ads and startup animation from gdlauncher. it uses the ability to compile the app.asar file without loosing functionality (no api key needed) to generate a new one with the react components for showing ads stripped out
diff --git a/apps/desktop/packages/main/adSize.ts b/apps/desktop/packages/main/adSize.ts
index 8ab38784..bdf2777a 100644
--- a/apps/desktop/packages/main/adSize.ts
+++ b/apps/desktop/packages/main/adSize.ts
@@ -17,8 +17,8 @@ export default function getAdSize(display?: Display) {
adSize: {
useFallbackAd,
useVertical: true,
- width: 160,
- height: 600
+ width: 0,
+ height: 0
}
};
} else {
@@ -30,9 +30,9 @@ export default function getAdSize(display?: Display) {
adSize: {
useFallbackAd,
useVertical: false,
- width: 400,
- height: 600
+ width: 0,
+ height: 0
}
};
}
-}
+}
\ No newline at end of file
diff --git a/apps/desktop/packages/mainWindow/src/components/AdBanner.tsx b/apps/desktop/packages/mainWindow/src/components/AdBanner.tsx
index 657870ca..5231cbd0 100644
--- a/apps/desktop/packages/mainWindow/src/components/AdBanner.tsx
+++ b/apps/desktop/packages/mainWindow/src/components/AdBanner.tsx
@@ -2,13 +2,7 @@ import adSize from "@/utils/adhelper";
export const AdsBanner = () => {
return (
- <div
- style={{
- height: `${adSize.height}px`,
- width: `${adSize.width}px`
- }}
- >
- <owadview class="relative z-100" />
+ <div>
</div>
);
};
diff --git a/apps/desktop/packages/mainWindow/src/global.d.ts b/apps/desktop/packages/mainWindow/src/global.d.ts
index 8a25b565..17f1b75e 100644
--- a/apps/desktop/packages/mainWindow/src/global.d.ts
+++ b/apps/desktop/packages/mainWindow/src/global.d.ts
@@ -56,9 +56,9 @@ declare global {
declare module "solid-js" {
namespace JSX {
- interface IntrinsicElements {
+ /*interface IntrinsicElements {
owadview: any;
- }
+ }*/
}
}
diff --git a/apps/desktop/packages/mainWindow/src/pages/withAds.tsx b/apps/desktop/packages/mainWindow/src/pages/withAds.tsx
index 50c6462a..c19b7699 100644
--- a/apps/desktop/packages/mainWindow/src/pages/withAds.tsx
+++ b/apps/desktop/packages/mainWindow/src/pages/withAds.tsx
@@ -69,35 +69,7 @@ function withAdsLayout() {
<Outlet />
</div>
<div class="flex flex-col justify-between h-[calc(100vh-100px)]">
- <div
- class="bg-darkSlate-800 py-4"
- style={{
- width: `${adSize.width}px`,
- height: `${adSize.height}px`
- }}
- >
- <Show when={adSize.shouldShow}>
- <Switch>
- <Match when={adSize.useFallbackAd}>
- <BisectBanner />
- </Match>
- <Match when={!adSize.useFallbackAd}>
- <AdsBanner />
- </Match>
- </Switch>
- </Show>
- </div>
<div class="flex justify-center">
- <div
- class="text-center hover:text-darkSlate-50 transition-colors duration-200 text-darkSlate-200"
- onClick={() => {
- modalContext?.openModal({
- name: "whyAreAdsNeeded"
- });
- }}
- >
- <Trans key="why_are_ads_needed" />
- </div>
</div>
</div>
<div class="absolute top-0 left-0 right-0 bottom-0 bg-image-gdlauncher_pattern.svg -z-10" />
@GameTec-live
Copy link
Author

setup the build enviroment as instructed in the gdlauncher repo:

  • npm install -g pnpm
  • pnpm i

create a .env file in the root of the project with the following contents:

USER_AGENT_PREFIX = ""
MS_AUTH_CLIENT_ID = ""
META_BASE_URL = ""
BASE_API = ""
RUNTIME_PATH = ""
  • pnpm codegen

now, deviate from the instructions and run:
pnpm build:win-x64
in the root of the git cloned project (IMPORTANT, it must be cloned)

when complete youll find a newly compiled app.asar in ./apps/desktop/release/win-unpacked/resources
just copy it into your gdlaunchers install and overwrite the existing one. (eg: C:\Users\user\AppData\Local\Programs\gdlauncher\resources)

@Official-Husko
Copy link

Does this still work? It throws a shit ton of errors at me at the step pnpm codegen.

error: could not compile "carbon_app" (bin "carbon_app") due to previous error

@GameTec-live
Copy link
Author

it still works, maybe some problem in your toolchain... got rust setup?

@Official-Husko
Copy link

it still works, maybe some problem in your toolchain... got rust setup?

I should have rust setup yes:

rustup 1.26.0 (5af9b9484 2023-04-05)
rustc 1.74.0 (79e9716c9 2023-11-13)

NodeJS: v18.17.0
npm: v9.6.7
pnpm: v8.15.6

Here is what i did:

  1. clone the repo into a folder (git clone https://github.com/gorilla-devs/GDLauncher-Carbon)
  2. npm install -g pnpm
  3. pnpm i
  4. git apply < adsbegone-gdlauncher-carbon.patch
  5. create .env file with the contents
  6. pnpm codegen

@GameTec-live
Copy link
Author

hm, interesting... what is the error of the codegen command?

@Official-Husko
Copy link

hm, interesting... what is the error of the codegen command?

its so long that it goes off the terminal scroll space. So i can't pin the exact cause sadly.

@GameTec-live
Copy link
Author

weird... Cant really help you there then sadly... I can send you my compiled asar file though... (keybase, discord, whatever)

@Official-Husko
Copy link

Official-Husko commented Apr 7, 2024

weird... Cant really help you there then sadly... I can send you my compiled asar file though... (keybase, discord, whatever)

Thank you for the offer but i really would like to get this working on my end directly because if it worked for you it has to work for me too right? I can't be this unlucky that it just flat out refuses to work.

Edit: I think i have solved the issue. Probably something on my setup somehow. Thank you for this.

@GameTec-live
Copy link
Author

makes sense... nice that you got it to work 👍
Ofc, to retain full functionality, only replace the app.asar... replacing the binary or other stuff might cause you to loose the curseforge api token and therefore use functionality...

@Official-Husko
Copy link

makes sense... nice that you got it to work 👍 Ofc, to retain full functionality, only replace the app.asar... replacing the binary or other stuff might cause you to loose the curseforge api token and therefore use functionality...

Most likely it will break shit yes but that's okay. I plan to only modify the app.asar anyways.

@Freedbot
Copy link

Freedbot commented Apr 12, 2024

Doing a full copy and compile is quite a bit of work just to patch out ads. I've done it, and it works, but since it's using the source branch, that puts you automatically in the beta version. As you'd expect, I was using the stable release. Using this method has 2 downsides: 1. Unless change settings and update to the Beta release, the update button shows up and of course will replace the patched file and revert to stable. 2. The ads may be gone, but now there's the obnoxious Beta Release warning banner across the top of the app, which slightly defeats the purpose.

I'm not familiar with how to edit the patch, but it seems you just need to either not load or blank out the functions return in UnstableCard.tsx

@Freedbot
Copy link

Freedbot commented Apr 12, 2024

Figured it out.... I added this. I didn't need to remove the unused references, but meh.

index 5ffc0178..05a3d0ce 100644
--- a/apps/desktop/packages/mainWindow/src/components/UnstableCard.tsx
+++ b/apps/desktop/packages/mainWindow/src/components/UnstableCard.tsx
@@ -1,46 +1,5 @@
-import { Trans } from "@gd/i18n";
-import { Match, Switch } from "solid-js";
-
 const UnstableCard = () => {
-  const isSnapshotRelease = __APP_VERSION__.includes("-snapshot");
-  const isBetaRelease = __APP_VERSION__.includes("-beta");
-  const isAlphaRelease = __APP_VERSION__.includes("-alpha");
-  return (
-    <div>
-      <Switch>
-        <Match when={isSnapshotRelease}>
-          <div class="flex flex-col w-full box-border mb-8">
-            <div class="flex w-full justify-center items-center h-10 font-bold box-border bg-red-900">
-              <Trans key="adbanner.snapshot_title" />
-            </div>
-            <div class="w-full box-border flex-wrap border-1 border-darkSlate-600 p-4 rounded-xl border-x-solid border-b-solid">
-              <Trans key="adbanner.snapshot_text" />
-            </div>
-          </div>
-        </Match>
-        <Match when={isBetaRelease}>
-          <div class="flex flex-col w-full box-border mb-8">
-            <div class="flex w-full justify-center items-center h-10 font-bold box-border bg-yellow-900">
-              <Trans key="adbanner.beta_title" />
-            </div>
-            <div class="w-full box-border flex-wrap p-4 border-1 border-darkSlate-600 rounded-xl border-x-solid border-b-solid">
-              <Trans key="adbanner.beta_text" />
-            </div>
-          </div>
-        </Match>
-        <Match when={isAlphaRelease}>
-          <div class="flex flex-col w-full box-border mb-8">
-            <div class="flex w-full justify-center items-center h-10 font-bold box-border bg-red-900 rounded-t-xl">
-              <Trans key="adbanner.alpha_title" />
-            </div>
-            <div class="w-full box-border flex-wrap p-4 border-1 border-darkSlate-600 rounded-xl border-x-solid border-b-solid">
-              <Trans key="adbanner.alpha_text" />
-            </div>
-          </div>
-        </Match>
-      </Switch>
-    </div>
-  );
+  return <div />;
 };
 
 export default UnstableCard;

@GameTec-live
Copy link
Author

idk what beta branch your in, but for me there isnt a "beta warning"... You should probably update your launcher with the latest build from the gdl discord...

@Freedbot
Copy link

Freedbot commented Apr 14, 2024

Wha..? No dude. I'm saying the program has release channels. When you download the source from the default "develop" branch, you get the latest version. If you download it when it's similar to the stable release version, then no problem. I'm guessing the version number is stored in app.asar. If the latest source... for example, happens to have a version number that ends in "-beta". Then you'll see a banner saying as much. Also, while getting pictures for this I've found another problem. This program automatically self updates on close, and it doesn't have a setting to disable this. If I don't go into settings and select the "beta" branch to match the app.asar I've built, then it gets wiped on close to put me back on "stable". So the next question is how do I disable the update check? Would finding and incrementing the version number to 9999999 and removing the "-beta" be a better solution?

image
image

@Freedbot
Copy link

The version info is "packages/config/version.json". I've edited it for myself to increase the version number and edit the "channel": "beta" line to "channel": "AdlessPatch" as an alternative way to remove the banner and possibly prevent auto-updating. It's a dumb way to do it, and might not work, but I'm too lazy and lacking confidence to properly disable the auto-update function without breaking things.

@RhapsodySL
Copy link

Hi, would you be able to provide a copy of the app.asar? I've been trying to set up a build environment for this but have been running into a similar issue as above and am unable to resolve it.

@GameTec-live
Copy link
Author

@RhapsodySL You can contact me via discord or similar if you want, but setting it up yourself is the ideal as i dont know your update freqency and youd want to avoid a version mismatch...

@RhapsodySL
Copy link

The version info is "packages/config/version.json". I've edited it for myself to increase the version number and edit the "channel": "beta" line to "channel": "AdlessPatch" as an alternative way to remove the banner and possibly prevent auto-updating. It's a dumb way to do it, and might not work, but I'm too lazy and lacking confidence to properly disable the auto-update function without breaking things.

Gave this a try and it does indeed work, but I found that every time the application opens or whenever you switch to the Library tab from another tap, it opens a popup showing the changelog for the version even if it's already displayed it before. I don't suppose anyone would know anything about how to get rid of that?

@Freedbot
Copy link

I don't have that problem, so you've got something edited differently or they did an update in the last week that messes with it. It's been working for me, but I've had other minor bugginess from using this jank home built beta.

@RhapsodySL
Copy link

I don't have that problem, so you've got something edited differently or they did an update in the last week that messes with it. It's been working for me, but I've had other minor bugginess from using this jank home built beta.

The only changes I've made are applying the patch file from the original post, and changing my version.json to this:

{
"version": "3.0.0",
"channel": "AdlessPatch"
}

Did you change anything else? What did you set the contents of your version.json to?

@GameTec-live
Copy link
Author

id not touch the versions.json but just change the updater .yml file in the resources folder...

@RhapsodySL
Copy link

id not touch the versions.json but just change the updater .yml file in the resources folder...

What file? I wasn't able to find that.

@GameTec-live
Copy link
Author

theres a .yml file next to the asar in the resources folder (of the installed launcher)... Changing that should work better...

@Freedbot
Copy link

@RhapsodySL that's not significantly different from what I did except that I set my version to 999.999.999 just to be extreme about it. It should have still worked the same. GameTec is right of course. The best answer is to edit and disable the updater altogether. I didn't post the contents directly because I knew it was a hacky trick, but it was relatively easy to find and mess with. It's worth repeating that this is the active source we're using. They're doing edits there every couple days that could cause as many bugs as they're fixing until they build and release it themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment