Conversation
See the last 6 comments on issue #25 #25 (comment)
|
can even make the whole extension be: const script = document.createElement('script');
script.textContent = 'setInterval(() => window._lact = Date.now(), 900000);';
script.onload = function () {
this.remove();
};
(document.head || document.documentElement).appendChild(script);btw I have tested this method for hundred of hours and never had problems |
|
@Araxeus But now the logging functionality is there. So you can see when it resets the time. Other, like your code, you can't see when it does something. |
|
The whole point is that you dont need to see anything - this just works no logging needed 😋 logging that the interval is working every 15 min isn't achieving anything IMO (its fine for initial testing, not very useful for deployment) |
@Araxeus That's true |
|
yeah well also if u wanna use manifest v3 in chrome it doesn't work this way you have to inject an external page, like so: function loadPageAccess() {
const pageAccess = document.createElement('script');
pageAccess.src = chrome.runtime.getURL('pageAccess.js');
pageAccess.onload = function () {
this.remove();
};
(document.head || document.documentElement).appendChild(pageAccess);
}but then its funny cuz pageAccess.js will be just setInterval(() => window._lact = Date.now(), 900000);and in the manifest (should probably also update to v3) "web_accessible_resources": [
{
"resources": [ "pageAccess.js" ],
"matches": [ "https://www.youtube.com/*", "https://music.youtube.com/*" ]
}
],like in my extension https://github.com/Araxeus/Youtube-Volume-Scroll/blob/main/manifest.json |
|
You don't need a Because now it reads: |
|
I dont know whats the purpose of that popup you dont have to remove it tho |
|
|
||
| function log(message) { | ||
| console.log(`${tag}[${getTimestamp()}] ${message}`); | ||
| } |
There was a problem hiding this comment.
This can be:
function log(message) {
console.log(`${tag}[${getMilliseconds()}] ${message}`);
}
| let time = asDoubleDigit(dt.getHours()) + ':' + asDoubleDigit(dt.getMinutes()) + ':' + asDoubleDigit(dt.getSeconds()); | ||
| let time = dt.getHours() + ':' + dt.getMinutes() + ':' + dt.getSeconds(); | ||
| return time; | ||
| } |
There was a problem hiding this comment.
This can be:
function getMilliseconds() {
return +new Date();
}
| log(`Monitoring YouTube ${isYoutubeMusic ? 'Music ' : ''}for 'Confirm watching?' action...`); | ||
| } + | ||
| ')();'; | ||
|
|
There was a problem hiding this comment.
This whole file can be:
const script = document.createElement('script');
script.textContent = 'setInterval(() => window._lact = Date.now(), 900000);';
script.onload = function () {
this.remove();
};
(document.head || document.documentElement).appendChild(script);
If you don't need any logging in the console.
JohnyP36
left a comment
There was a problem hiding this comment.
See #43 (comment) for a much sorter version.
Besides, your extension will be Manifest v3 (instead of v2).
Make use of YouTube's own events (see lawfx/YoutubeNonStop#43)
See the last 6 comments on issue #25 #25 (comment)