Skip to content

Commit

Permalink
Fix importing ipcRenderer in the webview-imported script
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Apr 14, 2022
1 parent 0437aed commit 52769a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export const useSpotifyPlaylistImporterProps = (t: TFunction<string>) => {
const ipcRenderer = window.require('electron').ipcRenderer;
(${extractPlaylist.toString()})()
})()`
.replaceAll('electron__WEBPACK_IMPORTED_MODULE_0__.', '');
.replaceAll('electron__WEBPACK_IMPORTED_MODULE_0__.', '')
.replaceAll('a(\'electron\')', 'window.require(\'electron\'))');

w.executeJavaScript(js);
}, 1500);
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/helpers/playlist/spotify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ipcRenderer } from 'electron';

/* eslint-disable node/no-extraneous-require */
/* eslint-disable @typescript-eslint/no-var-requires */
type SpotifyTrack = {
index: number;
id?: string;
Expand All @@ -19,6 +19,8 @@ type SpotifyPlaylist = {
}

export default (async function () {
const { ipcRenderer } = window.require('electron');

function getPlaylistGeneralInfo() {
const tracklistContainer = document.querySelector('div[data-testid="playlist-tracklist"]');
const totalTracks = parseInt(
Expand All @@ -45,7 +47,6 @@ export default (async function () {
}

function getTracksFromDOM(processedIndex) {

const nodeTracks = document.querySelector('div[data-testid="top-sentinel"] + div').childNodes as NodeListOf<Element>;
const tracks = [];

Expand Down Expand Up @@ -139,7 +140,6 @@ export default (async function () {
y += scrollHeight;

await wait(1000);

}

playlist.tracks = extractedTracks;
Expand Down

0 comments on commit 52769a2

Please sign in to comment.