Skip to content
Open
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
60 changes: 60 additions & 0 deletions plugins/inview/main/plugin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { definePlugin } from "@revenge/plugin";
import React, { useState } from "react";

export default definePlugin({
name: "InView",
description: "Open WebView instead of classic browser",

onStart() {
const originalOpen = window.open;
window.open = (url: string, name?: string) => {
showWebView(url, name || url);
};
},

onStop() {
window.open = originalOpen;
},
});

function showWebView(url: string, title: string) {
// React
const modal = document.createElement("div");
document.body.appendChild(modal);

const WebViewModal = () => {
const [visible, setVisible] = useState(true);

if (!visible) return null;

return (
<div style={{
position: "fixed",
top: 0, left: 0,
width: "100%", height: "100%",
backgroundColor: "#111",
zIndex: 9999,
display: "flex",
flexDirection: "column"
}}>
<div style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
backgroundColor: "#222",
color: "#fff",
padding: "8px"
}}>
<span>{title} - {url}</span>
<div>
<button onClick={() => window.open(url, "_blank")} style={{marginRight: "8px"}}>🌐</button>
<button onClick={() => setVisible(false)}>✕</button>
</div>
</div>
<iframe src={url} style={{flex: 1, border: "none"}} />
</div>
);
};

React.render(<WebViewModal />, modal);
}
11 changes: 11 additions & 0 deletions plugins/inview/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "InView",
"description": "Open WebView instead of browser",
"version": "0.1",
"author": "Tackus",
"license": "MIT",
"main": "plugin.tsx",
"type": "plugin",
"minAppVersion": "1.0.0",
"tags": ["webview", "links", "ui", "tackus"]
}