Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,7 @@
<title>GD Video Player</title>
<link rel="stylesheet" href="./style.css" />

<!-- Trick for JQuery: Insert this line above script imports -->
<script>
if (typeof module === 'object') {
window.module = module
module = undefined
}
</script>

<!-- normal script imports etc -->
<script src="./scripts/jquery.min.js"></script>

<!-- Insert this line after script imports -->
<script>
if (window.module) module = window.module
</script>
</head>

<body>
Expand Down
8 changes: 4 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
const { app, BrowserWindow } = require('electron')
const path = require('path')

app.allowRendererProcessReuse = true

function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
Expand All @@ -13,8 +11,10 @@ function createWindow() {
maximizable: true,
resizable: false,
webPreferences: {
webviewTag: true,
nodeIntegration: true,
contextIsolation: true,
sandbox: true,
nodeIntegration: false,
webviewTag: false,
preload: path.join(__dirname, 'preload.js')
}
Comment thread
gomgom marked this conversation as resolved.
})
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"dist": "electron-builder"
},
"devDependencies": {
"asar": "^2.1.0",
"electron": "^13.6.6",
"electron-builder": "^22.4.0",
"electron-packager": "^14.2.1"
"asar": "^3.2.0",
"electron": "^43.0.0",
"electron-builder": "^26.15.3",
"electron-packager": "^17.1.2"
},
"dependencies": {},
"license": "MIT",
Expand Down
14 changes: 12 additions & 2 deletions preload.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const { contextBridge, ipcRenderer } = require('electron')

const VALID_SIZES = ['small', 'medium', 'large']

contextBridge.exposeInMainWorld('gdPlayer', {
resizeWindow: (size) => {
if (!VALID_SIZES.includes(size)) return
ipcRenderer.send(`resize-window-${size}`)
},
maximize: () => ipcRenderer.send('maximize'),
toggleAlwaysOnTop: () => ipcRenderer.send('always-on-top')
})
36 changes: 20 additions & 16 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
$(function() {
$('#load_button').click(function() {
url = $('#url').val()
id = null
const url = $('#url').val()
let id = null

// 입력된 값에서 ID 추출
if (url.match(/^https:\/\/drive\.google\.com\/open\?id\=(.*)/g)) {
id = url.split('=')[1]
// 입력된 값에서 ID 추출 (기존 open?id=... 링크와 현재 file/d/ID/view 링크 모두 지원)
try {
const parsed = new URL(url)
const fileMatch = parsed.pathname.match(/^\/file\/d\/([^/]+)/)
if (fileMatch) {
id = fileMatch[1]
} else if (parsed.pathname === '/open' && parsed.searchParams.has('id')) {
id = parsed.searchParams.get('id')
}
} catch (e) {
id = null
}

// ID를 찾으면 작업 처리
if (id) {
// 플레이어 삽입 스크립트
player = '<iframe id="player_iframe" src="https://drive.google.com/file/d/' + id + '/preview" webkitallowfullscreen mozallowfullscreen allowfullscreen></webview>'
const player = '<iframe id="player_iframe" src="https://drive.google.com/file/d/' + id + '/preview" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'

$('#player').html(player)
$('#window_size').css('display', 'inline')
Expand All @@ -29,13 +37,12 @@
}
$('#window_size span').click(function() {
size = $(this).attr('id')
const { ipcRenderer } = require('electron')
if (size == 'w_small') {
ipcRenderer.send('resize-window-small')
window.gdPlayer.resizeWindow('small')
} else if (size == 'w_medium') {
ipcRenderer.send('resize-window-medium')
window.gdPlayer.resizeWindow('medium')
} else if (size == 'w_large') {
ipcRenderer.send('resize-window-large')
window.gdPlayer.resizeWindow('large')
}
if (typeof(size_list[size]) != 'undefined') {
width = size_list[size]
Expand All @@ -46,13 +53,11 @@
})

$('#always_on_top').click(function() {
const { ipcRenderer } = require('electron')
ipcRenderer.send('always-on-top')
window.gdPlayer.toggleAlwaysOnTop()
})

$('#maximize').click(function() {
const { ipcRenderer } = require('electron')
ipcRenderer.send('maximize')
window.gdPlayer.maximize()

$('#player').css('width', "95%")
$('#player').css('height', "90%")
Expand All @@ -62,8 +67,7 @@
})

$('#unmaximize').click(function() {
const { ipcRenderer } = require('electron')
ipcRenderer.send('resize-window-small')
window.gdPlayer.resizeWindow('small')
width = 700
height = Math.round(width * 0.5625)
$('#player').css('width', width)
Expand Down