Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.29k stars 424 forks source link

Tampermonkey beta 5.2.6197 cannot be run every time after restarting Chrome. You need to close the extension and then open it again. #2075

Closed Tback1 closed 5 months ago

Tback1 commented 5 months ago

Tampermonkey cannot be run every time after restarting Chrome. You need to close the extension and then open it again.And it can only be closed in the expansion management. After closing and opening again, everything will be normal. But after restarting Chrome, it doesn’t work again.

image

image

image

Specifications

image

derjanb commented 5 months ago

Thanks for reporting this issue!

A quick fix is to execute this at the service worker console. After this everything should work as expected.

(async () => {
    const dNR = chrome.declarativeNetRequest;
    const dr = await dNR.getDynamicRules();
    await dNR.updateDynamicRules({ removeRuleIds: dr.map(r => r.id)});
    console.log('done');
})();
Tback1 commented 5 months ago

Thanks for reporting this issue!

A quick fix is to execute this at the service worker console. After this everything should work as expected.

(async () => {
    const dNR = chrome.declarativeNetRequest;
    const dr = await dNR.getDynamicRules();
    await dNR.updateDynamicRules({ removeRuleIds: dr.map(r => r.id)});
    console.log('done');
})();

Thanks but it's done , and not solve this image

image

derjanb commented 5 months ago

Yes, wrong movie... Sorry. I'll investigate this further...

derjanb commented 5 months ago

Can you please run this snippet and attach the output here? You can remove 'userscript-api' entries if any.

(async () => {
    const usc = chrome.userScripts;
    const all = await usc.getScripts();
    console.log('before remove', all);
})();

Then please run this and check if the output changes and whether tzis fixes the issue. Thanks!

(async () => {
    const usc = chrome.userScripts;
    await usc.unregister({ ids: ['content|mtwhl|r'] });
    const all = await usc.getScripts();
    console.log('after remove', all);
})();
Tback1 commented 5 months ago

Sorry there some work I can't restart browser after test the code still no effect image

image

Tback1 commented 5 months ago

image

Even after I disable and enable the Tampermonkey extension, there are still some error messages in the devtool

in the runtime, the error add very fast

image

derjanb commented 5 months ago

OK. Thanks. Then please run this as final test:

(async () => {
    const usc = chrome.userScripts;
    let all = await usc.getScripts();    
    await usc.unregister({ ids: all.map(s => s.id) });
    all = await usc.getScripts();
    console.log('after remove', all);
})();
Tback1 commented 5 months ago

OK. Thanks. Then please run this as final test:

(async () => {
    const usc = chrome.userScripts;
    let all = await usc.getScripts();    
    await usc.unregister({ ids: all.map(s => s.id) });
    all = await usc.getScripts();
    console.log('after remove', all);
})();

unfortunately, it's still not solve the question image

derjanb commented 5 months ago

Unfortunately I have no idea how this can happen. It looks like code is being executed twice, which can't happen...

Can you please go to chrome://serviceworker-internals/, search for the gcal... entry and stop and unregister the service worker? Then please restart Chrome.

derjanb commented 5 months ago

Tested with 125.0.6422.112 and 125.0.6422.113. Maybe this is a 125.0.6422.61 issue? Can you update your Chrome?

derjanb commented 5 months ago

Please also try 5.2.6198 (crx) *. It won't fix the underlying issue, but Tampermonkey should at least start again so that you can export your scripts. Then would it be possible to test again using a new temporary Chrome profile?

* Just download the crx file linked above and drag and drop it to the extensions page chrome://extensions (after you've enabled 'Developer Mode').

Tback1 commented 5 months ago

Unfortunately I have no idea how this can happen. It looks like code is being executed twice, which can't happen...

Can you please go to chrome://serviceworker-internals/, search for the gcal... entry and stop and unregister the service worker? Then please restart Chrome.

NOT SOLVE image

console output:

Console: {"lineNumber":452,"message":"alarm: onAlarm[w6juolpvpc] [object Object]","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Console: {"lineNumber":452,"message":"alarm: onAlarm[w6juolpvpc] mutex acquired [object Object] [object Object]","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Console: {"lineNumber":454,"message":"alarm: internalClear w6juolpvpc","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Console: {"lineNumber":454,"message":"alarm: internalClear done w6juolpvpc [object Object] [object Object]","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Console: {"lineNumber":453,"message":"alarm: onAlarm[w6juolpvpc] mutex release","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Console: {"lineNumber":452,"message":"alarm: onAlarm[0mbk8bdycm] [object Object]","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Console: {"lineNumber":452,"message":"alarm: onAlarm[0mbk8bdycm] mutex acquired [object Object] [object Object]","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Console: {"lineNumber":453,"message":"alarm: onAlarm[0mbk8bdycm] mutex release","message_level":0,"sourceIdentifier":3,"sourceURL":"chrome-extension://gcalenpjmijncebpfijmoaglllgpjagf/background.js"}
Tback1 commented 5 months ago

Tested with 125.0.6422.112 and 125.0.6422.113. Maybe this is a 125.0.6422.61 issue? Can you update your Chrome?

updated to 125.0.6422.113 still image

Tback1 commented 5 months ago

Please also try 5.2.6198 (crx) *. It won't fix the underlying issue, but Tampermonkey should at least start again so that you can export your scripts. Then would it be possible to test again using a new temporary Chrome profile?

  • Just download the crx file linked above and drag and drop it to the extensions page chrome://extensions (after you've enabled 'Developer Mode').

this version solve this question. 🎉🎉🎉 but still same error console output

1.in the new blank profile ,it's work image

2.in my daily profile . it's work well too. image

3 runtime error image

image

Although 5.2.6198 has solved this problem for the time being. But I still have some concerns: I don't know if you noticed that I mentioned

TM can run after each restart and then manually opened and closed

because it seems that you mentioned

but Tampermonkey should at least start again so that you can export your scripts

I am worried that you think that TM cannot be started and cannot export configurations and scripts here. This is not the case. The reason why I have no idea is that it can work normally after closing and opening it again in this browser.

But thank God, at least this version solves some problems