Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gazmull
Last active March 9, 2023 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gazmull/ed5da217da1bad807425f58feee3d39a to your computer and use it in GitHub Desktop.
Save gazmull/ed5da217da1bad807425f58feee3d39a to your computer and use it in GitHub Desktop.
Kamihime PROJECT NTK - Bypass New DL Because the Game Sucks

Uriel is Probably Gay

Have you ever felt that as soon as you read this, you already wasted 4 hours of reading? FOUR. HOURS!one1!!1!one1

tl;dr: For Kamihime PROJECT (NTK ver.) game. Bypasses the new "DL" because the game still sucks asshole. Yes. I just said yes.

What's New

Click here for full changelog

3.0.1 - 2023-02-03

  • Fixed broken URL for redirect

3.0.0 - 2022-11-25

  • Updated new direct link to address script not working
  • Optimised popup window
    • Popup window's background colour can be changed now

What is This Abomination?

If you "don't want to cheat on the game," then you need to leave now because I'm not gonna argue with a hypocrite. Yes this is considered cheating.

This is for those who can't take shit anymore with how garbage the game is with UX (e.g. Unnecessary Nikes, connecting). That's it.

Also customisable such as fixing the stretched game screen resolution by yourself (userscript settings; check below on how to access it). Works on both .net/.com versions.

Disclaimer: I'm not responsible if something ever happens to your account. Think before you click! Also this is open source to see for yourself on how safe it is.

How To

This has been tested with only Chromium-based browsers. Feel free to try it on other browsers.

  1. You need a userscript manager browser extension such as Tampermonkey (TM) (Recommended)
  2. Once the browser extension is installed, scroll down to hardbass.user.js file and click the raw button beside it. It should prompt you installation of the userscript.
    1. If this doesn't work, then click "new userscript" button or similar (+ button in TM's case) then paste the code of the aforementioned file to the new userscript tab.
  3. Go to the regular game window like how you were doing it before, then just wait for a new window to pop up or a redirection and you may safely close the normal game window. If it failed to pop up a new window or redirect you to game URL, allow it to do redirect/pop up (in Site Settings/Permissions).
    1. Definitely, you can go to the game URL by yourself after you got the alert if it cannot redirect/popup and you don't want to modify the site permissions
  4. That's it... why are you still reading this? Have you ever licked Sol's cheek to see whether she's lying? She's lying, I tell you!
  5. Hey, listen to this music https://www.youtube.com/watch?v=4w2icYjruEY
  6. How about this one instead https://www.youtube.com/watch?v=l-_klDWv250
  7. Yes

Something to Note

  • It always fetches fresh session tokens in case you need to reload the game or come back to the game a little bit later
    • Just to be safe, the userscript invalidates session tokens that were updated an hour ago. You'll need to go to normal game window again if you ever left for over an hour
    • Don't ever share the data stored by this userscript to anyone! It's only used by you and yourself.
  • How to access userscript settings:

image

Download

Did you actually read this README file? If not, go read this again.

Support

Feel free to contact my Discord Euni#1200 if you need help with something related to this userscript. I don't bite but I break my back.

Changelog

3.0.1 - 2023-02-03

  • Fixed broken URL for redirect

3.0.0 - 2022-11-25

  • Updated new direct link to address script not working
  • Optimised popup window
    • Popup window's background colour can be changed now

2.1.2 - 2021-11-04

  • Revert GM4 API due to GM_config incompatibility

2.1.1 - 2021-11-04

  • Optimised popup method's window size

2.1.0 - 2021-22-03

  • Added customisation panel
    • Disable/Enable popup method
    • Popup window size

2.0.0 - 2021-19-03

  • BREAKING CHANGE: Revised fixing stretched game screen resolution strategy
    • Now it pops up a new window instead of redirecting due to in-game UI issues

1.0.0 - 2021-17-03

Uriel is Probably Gay Edition

  • Added fix for stretched game resolution
  • Added fresh session tokens preservation for reloading
  • Fixed ugly prompts

0.1.0 - 2021-13-03

Initial release

License

MIT

(c) 2021-2022 gazmull (https://thegzm.space)

/* eslint-disable max-len */
// ==UserScript==
// @name Kamihime Project NTK - Bypass New DL
// @version 3.0.1
// @icon https://g.pikan.party/wiki/portrait/(Dream%20Cotton%20Spiral)%20Uriel%20Portrait.png
// @description Have you ever felt that as soon as you read this, you already wasted 4 hours of reading? FOUR. HOURS!one1!!1!one1
// @author Eunicorn
// @license MIT
// @homepage https://thegzm.space
// @match https://pf.nutaku.com/*
// @match https://osapi.nutaku.com/*
// @match https://gnkh-api-r.prod.nkh.dmmgames.com/front/cocos2d-proj/components-pc/game/app.html
// @match https://gnkh-api-g.prod.nkh.dmmgames.com/front/cocos2d-proj/components-pc/game/app.html
// @match https://gnkh-api-r.prod.nkh.dmmgames.com/front/cocos2d-proj/components-sp/game/app.html
// @match https://gnkh-api-g.prod.nkh.dmmgames.com/front/cocos2d-proj/components-sp/game/app.html
// @run-at document-start
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_setClipboard
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
// ==/UserScript==
/* eslint-enable max-len */
/* globals GM_config, kh, Q */
const gm = {
key: 'Ramiel_Sucks_Her_Own_Dick_Yes_Stop_Reading_Me_GTFO',
async getCredentials () {
const settings = await GM_getValue(this.key, undefined);
if (!settings) return undefined;
return JSON.parse(settings);
},
async setCredentials (key, val) {
const creds = (await this.getCredentials()) || { };
if (!key) return GM_setValue(this.key, '');
Object.assign(creds, {
[key]: val,
updated: new Date().valueOf()
});
return GM_setValue(this.key, JSON.stringify(creds));
}
};
// GM_Config
/* eslint-disable camelcase */
GM_config.init({
id: 'ramielcfg',
title: 'Bypass DL - Settings',
fields: {
popup: {
label: 'Popup Window',
type: 'checkbox',
default: true
},
size: {
label: 'Popup Window iFrame Size',
type: 'text',
default: '960x640'
},
colour: {
label: 'Popup Window Background Colour',
type: 'text',
default: '#000'
}
}
});
GM_registerMenuCommand('Bypass DL Settings', () => GM_config.open());
/* eslint-enable camelcase */
const SESSION_ID = 'sessionId';
const CSRF_TOKEN = 'csrfToken';
const RAMIEL_CFG_DEFAULT = '{ "popup": true, "size": "960x640" }';
function getHTML (width, height, colour, versionType, deviceType) {
/* eslint-disable indent */
return [
'<!DOCTYPE html>',
'<html>',
'<head>',
'<title>Uriel is Probably Gay</title>',
'</head>',
`<body style="background-color:${colour};">`,
'<p align="center">',
// eslint-disable-next-line max-len
`<iframe title="Ditto" src="https://gnkh-api-${versionType}.prod.nkh.dmmgames.com/front/cocos2d-proj/components-${deviceType}/game/app.html" width="${width}" height="${height}" />`,
'</p>',
'</body>',
'</html>',
].join('\n');
/* eslint-enable indent */
}
// function sleep (ms = 2e3) {
// return new Promise(res => setTimeout(res, ms));
// }
(async () => {
const ntkApiRegex = /^https:\/\/(?:pf|osapi)\.nutaku\.com\/gadgets\/ifr.*kamihime/i;
if (ntkApiRegex.test(window.location.href)) {
let lastUpdated = new Date().valueOf();
const interval = setInterval(async () => {
if (!kh || (kh && !kh.Session)) return;
if (!kh.Session.getCsrfToken() || !kh.Session.getSessionId()) return;
if ((new Date().valueOf() - lastUpdated) < 5e3) return;
await gm.setCredentials(CSRF_TOKEN, kh.Session.getCsrfToken());
await gm.setCredentials(SESSION_ID, kh.Session.getSessionId());
clearInterval(interval);
const deviceType = kh.env.isSp ? 'sp' : 'pc';
const versionType = kh.env.isR18 ? 'r' : 'g';
const url = [
`https://gnkh-api-${versionType}`,
`prod.nkh.dmmgames.com/front/cocos2d-proj/components-${deviceType}/game/app.html`,
].join('.');
try {
const gmc = JSON.parse(await GM_getValue('ramielcfg', RAMIEL_CFG_DEFAULT));
const sized = gmc.size.trim().split('x').filter(s => s).map(s => Number(s));
const [ width = 960, height = 640 ] = sized;
if (gmc.popup) {
// Keeps the window size intact, instead of going to DL right away
const newWindow = window.open('', '_blank', `width=${width + 25}, height=${height + 25}`);
newWindow.document.open();
newWindow.document.write(getHTML(width, height, gmc.colour, versionType, deviceType));
newWindow.document.close();
newWindow.focus();
window.alert('You can close this window now.');
} else top.window.location.href = url;
} catch (_) {
console.error(_);
await GM_setClipboard(url, 'text');
alert([
'Redirect/popup is disabled.',
'Please allow this site to redirect/popup or change script settings.',
'\nAnyhow: Game URL has been copied to your clipboard. You can access it now.',
].join('\n'));
}
}, 30);
return;
}
const creds = await gm.getCredentials();
const fail = async () => {
const isAdultVersion = /cf\.r/i.test(window.location.href);
const url = `https://nutaku.${isAdultVersion ? 'net' : 'com'}/games/kamihime${isAdultVersion ? '-r' : ''}/play`;
await GM_setClipboard(url, 'text');
return alert([
'You must go to normal game window first.',
'\nURL has been copied to your clipboard if you don\'t know it.',
].join('\n'));
};
if (!creds) return fail();
// If token already 1 hour last updated
if ((new Date().valueOf() - creds.updated) > 36e5) {
await gm.setCredentials(undefined);
return fail();
}
const interval = setInterval(() => {
if (!kh || (kh && !kh.GameSession)) return;
clearInterval(interval);
Object.defineProperties(kh.GameSession.prototype, {
awaitSetFirstSession: {
value () {
this._sendParentFrameFlag = false;
this.setSessionId(creds.sessionId, false, true);
this.setCsrfToken(creds.csrfToken, false, true);
return Q.resolve();
}
},
setSessionId: {
value (val, toParent = true, initial) {
this.set(SESSION_ID, val, toParent);
if (!initial) gm.setCredentials(SESSION_ID, val);
}
},
setCsrfToken: {
value (val, toParent = true, initial) {
this.set(CSRF_TOKEN, val, toParent);
if (!initial) gm.setCredentials(CSRF_TOKEN, val);
}
}
});
}, 30);
})();
@mintygamer77
Copy link

what game is dis for?

@gazmull
Copy link
Author

gazmull commented Feb 26, 2022

@Honorable001
Copy link

so this just for the game pop-ing up

@gazmull
Copy link
Author

gazmull commented Mar 9, 2023

It's the default behaviour. You can change it in userscript settings as stated in the README.

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