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

GM 4 Scripts Error: expected expression, got ')' #2670

Closed
erosman opened this issue Nov 15, 2017 · 10 comments
Closed

GM 4 Scripts Error: expected expression, got ')' #2670

erosman opened this issue Nov 15, 2017 · 10 comments
Milestone

Comments

@erosman
Copy link

erosman commented Nov 15, 2017

Hi

Working scripts under GM 3 fail under GM 4

Could not execute user script: [Greasemonkey Script .../....; 1.0] 
 Error: expected expression, got ')'
Stack trace:
Async*@moz-extension://ffbb8d40-70fc-42b4-9d63-f5ac882801f8/src/bg/execute.js:23:5
  execute.js:29:7

Any idea what the cause is?

Note: There is no JS error in the code. (tested)

After testing .... it seem the following fails

// ==UserScript==
// @name          Clean URL
// @namespace     erosman
// @description   Clean URLs
// @include       *
// @grant         none
// @author        erosman
// @version       1.0
// ==/UserScript==


(function() { 


})(); // end of anonymous function

Fix: adding an extra line or removing the end comment eliminates the error.

The following works fine .... (added a blank line)

// ==UserScript==
// @name          Clean URL
// @namespace     erosman
// @description   Clean URLs
// @include       *
// @grant         none
// @author        erosman
// @version       1.0
// ==/UserScript==
*/

(function() { 


})(); // end of anonymous function

Following works as well ... (removed the end comment)

// ==UserScript==
// @name          Clean URL
// @namespace     erosman
// @description   Clean URLs
// @include       *
// @grant         none
// @author        erosman
// @version       1.0
// ==/UserScript==
*/

(function() { 


})();
@erosman erosman changed the title All Scripts Error: expected expression, got ')' GM 4 All Scripts Error: expected expression, got ')' Nov 15, 2017
@erosman erosman changed the title GM 4 All Scripts Error: expected expression, got ')' GM 4 Scripts Error: expected expression, got ')' Nov 15, 2017
@Sxderp
Copy link
Contributor

Sxderp commented Nov 15, 2017

The way the parsing works is to create a function for the userscript and then call it. The current implementation defines the script on a single line. If the userscript ends in a comment than it causes the function definition to be invalid.

@Sxderp
Copy link
Contributor

Sxderp commented Nov 15, 2017

Submitted a pull to resolve the issue.

@arantius arantius added this to the 4.1 milestone Nov 15, 2017
@arantius
Copy link
Collaborator

Short term workaround: edit your scripts so they don't have a // line comment on the last line.

Will be fixed in next release.

@erosman
Copy link
Author

erosman commented Nov 15, 2017

Short term workaround: edit your scripts so they don't have a // line comment on the last line.

Obviously as pointed out in my initial post, I had already worked that out. ;)

@arantius
Copy link
Collaborator

Sorry you edited that in after your first post, so I didn't see it (read the message as delivered to my email).

@erosman
Copy link
Author

erosman commented Nov 15, 2017

Sorry you edited that in after your first post, so I didn't see it (read the message as delivered to my email).

Strange... since the edited post contains the data about it having a comment at the end. The original first post didn't have that information and only listed the error without showing the code.

@arantius
Copy link
Collaborator

Todo me (or @Sxderp ?) add a unit test to ensure this issue doesn't regress in the future.

@Sxderp
Copy link
Contributor

Sxderp commented Nov 15, 2017

Ah yes. I'll get on that. Submit as new pull request? If you want it in the same that'll be delaying the fix for a bit, unless you do it. Not sure when I can get around to the test cases[1].

[1] node and friends not setup

@arantius
Copy link
Collaborator

Base pull is already merged.

@Sxderp
Copy link
Contributor

Sxderp commented Nov 16, 2017

Added pull for tests

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

3 participants