Comments (12)
https://github.com/sentialx/electron-extensions/releases/tag/v3.0.0
from electron-extensions.
@Worie That's weird, because the audible
property is being recomputed on each call. I will need to investigate it.
from electron-extensions.
Yes. Same thing happens. You can see this commit: Worie/electron-quick-start@66b8a88 and run it on master from this fork: https://github.com/Worie/electron-quick-start .
from electron-extensions.
Hi, there is a tab
object in the sender
parameter. So you may want to use sender.tab.audible
.
from electron-extensions.
Thanks for fast reply! Missed that out. Unfortunately, audible
property is missing in sender.tab
.
{
"active":false,
"autoDiscardable":false,
"discarded":false,
"highlighted":false,
"id":2,
"incognito":false,
"index":2,
"pinned":false,
"selected":false,
"title":"localhost:9080",
"url":"http://localhost:9080/",
"windowId":2
}
I assume it's not implemented by electron
nor electron-extensions
then? Not sure if it's easy/possible to polyfill it somehow.
from electron-extensions.
nice! any plans for the release? :)
from electron-extensions.
You're always one step ahead :)
I'm just wondering - does this data that get's injected into tab
object is generated once, say per page load - or is it recomputing those properties (for example audible) per each reference?
I'm asking, because the extension that I am working on (and it has been working on Chromium itself) does something like this:
- Every N miliseconds, asks background script for audio playing in the tabs
- Background scripts replies with the tabs that are currently playing
- Content script gets this value injected into global scope via script tag, so it can be accessed on the client side.
Below the code, adjusted for Electron purposes.
manifest.json
{
"manifest_version": 2,
"name": "AudioDetector",
"version": "0.1",
"background": {
"scripts": [
// polyfill for promises
"chrome-extension-async.js",
"background.js"
]
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": ["content.js"],
"all_frames": true
}
],
"permissions": [
"tabs",
"http://*/",
"https://*/"
]
}
content.js
const startDetection = () => {
return new Promise(async (res, reject) => {
var port = chrome.runtime.connect({ name: "requestAudioState" });
setInterval(() => {
port.postMessage({});
}, 250);
port.onMessage.addListener(function requestAudio(msg) {
var elt = document.createElement("script");
elt.innerHTML = `
window.audioState = Boolean(${msg.playing});
`;
document.head.appendChild(elt);
elt.remove();
});
});
};
startDetection();
background.js
chrome.runtime.onConnect.addListener(async function (port) {
port.onMessage.addListener(async function handler(msg, obj) {
port.postMessage({
playing: obj.sender.tab.playing,
});
});
});
Visiting for example https://youtube.com/
should have window.audioState
false when no audio is played, and window.audioState
true when it does (that's the behavior working in Chromium).
Unfortunately, when I run this in electron using your package, it's always false
- thus I'm wondering whether the value gets recomputed on each call. If I send whole tab object to the content script (stringified) - it's exactly same object. Have you perhaps tested it to check whether audible
was true
in some scenarios? Can't get that to work. Ty!
from electron-extensions.
@Worie Okay, I published 4.0.0 to npm. Also, please be aware of breaking changes: https://github.com/sentialx/electron-extensions/releases/tag/v4.0.0
from electron-extensions.
Hey hey! TY for amazing support :)
Unfortunately, I'm still having issues after migrating to 4.0.*
.
When new import { ExtensibleSession } from 'electron-extensions/main';
is added to the project and I try to load extension with 👇
app.on('ready', () => {
const extensions = new ExtensibleSession(session.defaultSession);
extensions.loadExtension('/some-magic-path/audio-detector');
My electron app crashes and devtools get disconeccted (though my extension is not a devtools one) with such message:
Electron shows up with blank page. When I try to reload it, app seems loading - then devtools crash and the application goes blank.
This does not happen if I downgrade to 3.0.0
with import { ExtensibleSession } from 'electron-extensions';
- even though the audible
property is not recomputed, surely.
Package version and import is the only thing that has changed
from electron-extensions.
Could you reproduce it using electron-quick-start
?
from electron-extensions.
@Worie Okay, I published 4.0.2 with the fix.
from electron-extensions.
Nice! Now it's working like expected, ty! :)
from electron-extensions.
Related Issues (20)
- Skipping extension with invalid URL HOT 1
- Write tests
- adding crx HOT 2
- Tracking issue for Chrome APIs HOT 2
- objectToArray function mangles requestHeaders and responseHeaders HOT 1
- Does it work with content scripts that do not run in background page? HOT 4
- Question: Can we load extensions from Web Stor? HOT 1
- Status of electron 9 support HOT 1
- Known supported extensions HOT 2
- electron-extensions 7.0.0 HOT 4
- windows.create in background page HOT 1
- UnhandledPromiseRejectionWarning: TypeError: Cannot redefine property: webRequest
- Active loaded extension HOT 13
- Unable to load ublock origin HOT 4
- chrome.tabs.getSelected() should not return an array on 7.0.0-beta.2 HOT 1
- What does the License Mean? HOT 1
- How to properly open windows for browser Action popups HOT 11
- Support promise responses in WebRequest
- Cannot use import statement outside a module HOT 1
- Using PDF.JS as Chrome Extensions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-extensions.