Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggestion] clean function: A function to clean what the script has done when disabling it #2387

Closed
moham96 opened this issue Apr 10, 2016 · 7 comments

Comments

@moham96
Copy link

moham96 commented Apr 10, 2016

Don't know if this was suggested or implemented already but I'm going to write it anyway.
My idea is an API function that get invoked when the user disable a specific script inside a web page.
For example, i create a user script that adds some functions to facebook and also changes some of the tree nodes and styling obviously, so when a user is in a facebook page and want to disable the script from greasmonkey toolbar icon a function in the script (GM_clean maybe ?) get invoked, this function can be used to clean what the script has done to the web page (removing nodes and styles, cleaning some memory maybe).
Also a second function (GM_Enabled maybe) to be run when the script is enabled again

@janekptacijarabaci
Copy link
Contributor

You can refresh the page.

@eight04
Copy link

eight04 commented Apr 10, 2016

Any use case that the user will dis/enable a script often?

@moham96
Copy link
Author

moham96 commented Apr 10, 2016

You can refresh the page.

No kidding !

@moham96
Copy link
Author

moham96 commented Apr 10, 2016

Any use case that the user will dis/enable a script often?

I didn't say often, i personally use it when looking for a script that does a specific functionality, i always find multiple scripts that does the same functionality so i download them both and go to the webpage and then disable and enable each of the scripts to see which script does the job better

@cletusc
Copy link
Contributor

cletusc commented Apr 10, 2016

👎

Due to how many changes a script could make, there is no way for GM to do anything to "clean" what was done to a page. Creating a GM_onEnable and GM_onDisable would be interesting, but I would say most authors wouldn't use them, or if they did, they probably wouldn't reverse all changes.

For your use-case, I would personally say the best way to analyze multiple scripts is to analyze them separately: enable one, test it, disable, with refreshes in between.

@janekptacijarabaci
Copy link
Contributor

No kidding !

It was meant seriously (it's used commonly)...

@arantius
Copy link
Collaborator

Agreed, this would be useful only if every script used it, but few would bother.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants