Skip to content

Commit

Permalink
css injection does not seem to work when hyphe front is in https, swi…
Browse files Browse the repository at this point in the history
…tching back to JS removal after timeout instead
  • Loading branch information
boogheta committed Jan 8, 2021
1 parent 50401b0 commit 3c392cd
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions app/containers/BrowserContainer/HypheView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,24 @@ const HypheView = ({
useEffect(() => {
const webview = webviewRef.current

const inejectStyle = once(() => {
webview.executeJavaScript(`
const style = document.createElement('style');
style.textContent = ".topbar-project button, .topbar-project .flex, #hybro-link, .no-hybro { display: none !important; }";
document.head.append(style);
console.log(style);
`)
})

webview.addEventListener('did-start-loading', () => {
setLoading(true)
})
webview.addEventListener('did-stop-loading', () => {
setLoading(false)
inejectStyle()

webview.executeJavaScript(
webview.executeJavaScript(`
setTimeout(() => {
// Remove buttons from regular Hyphe front causing issues for HyBro (corpus name, close corpus button & link to HyBro)
document.querySelectorAll('.topbar-project button, .topbar-project .flex, #hybro-link, .no-hybro')
.forEach(node => node.parentNode.removeChild(node));
// Stop Sigma's ForceAtlas2 in Hyphe tab when changing tab to avoid cpu overhaul
"window.onblur = function() { if (document.querySelector('#stopFA2') !== undefined) document.querySelector('#stopFA2').click() }; "
)
window.onblur = function() {
if (document.querySelector('#stopFA2') !== undefined)
document.querySelector('#stopFA2').click()
};
}, 250)
`)
})

webview.addEventListener('new-window', ({ url }) => {
Expand Down

0 comments on commit 3c392cd

Please sign in to comment.