Skip to content

Instantly share code, notes, and snippets.

@ssig33
Created July 8, 2020 08:40
Show Gist options
  • Save ssig33/32eb23b49675a9de17cf6740e0a7ed69 to your computer and use it in GitHub Desktop.
Save ssig33/32eb23b49675a9de17cf6740e0a7ed69 to your computer and use it in GitHub Desktop.
<meta charset="utf-8" />
<title>Clipboard</title>
<div id="area"></div>
<script>
const electron = require("electron");
const ipc = electron.ipcRenderer;
const loop = async () => {
const text = ipc.sendSync("clipboard", "yokose");
document.querySelector("#area").textContent = text;
setTimeout(() => {
loop();
}, 2000);
};
loop();
</script>
<style>
body {
background-color: rgba(24, 24, 24, 0.7);
color: #fff;
-webkit-app-region: drag;
-webkit-user-select: none;
font-size: small;
margin: 0;
overflow: hidden;
}
</style>
const electron = require("electron");
const { clipboard } = require("electron");
const BrowserWindow = electron.BrowserWindow;
const app = electron.app;
const ipc = electron.ipcMain;
app.on("ready", () => {
const window = new BrowserWindow({
width: 200,
height: 40,
transparent: true,
alwaysOnTop: true
frame: false,
hasShadow: false,
webPreferences: {
nodeIntegration: true,
},
});
window.loadURL("file://" + __dirname + "/index.html");
window.setMenu(null);
ipc.on("clipboard", (e, a) => {
const text = clipboard.readText();
e.returnValue = text;
});
});
{
"name": "clip_widget",
"version": "0.0.1",
"main": "main.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment