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

Auto-Inject Version number in new Issues #31

Closed
mezmi opened this issue Mar 27, 2016 · 8 comments
Closed

Auto-Inject Version number in new Issues #31

mezmi opened this issue Mar 27, 2016 · 8 comments
Labels
Milestone

Comments

@mezmi
Copy link
Contributor

mezmi commented Mar 27, 2016

Installed Version: 1.0.3 DEV | Environment: Chrome/Tampermonkey

Expected Behavior

When creating an issue on GitHub, SOX should inject the currently installed version number into the post.

Actual Behavior

The version number is being injected, but only after a page refresh. I suspect a timing issue.

Related Code

var SOX_VERSION = '1.0.3 DEV';

// auto-inject version number into new GitHub issues
if (location.hostname.indexOf('github.com') > -1 ) {
    var $issue = $('#issue_body'),
        issueText = $issue.text();

    issueText = issueText.replace('1.X.X', SOX_VERSION);
    $issue.text(issueText);

    // on GitHub, stop execution of the rest of the script.
    return;
}
@mezmi mezmi added this to the v1.0.3 milestone Mar 27, 2016
shu8 added a commit that referenced this issue Mar 28, 2016
shu8 added a commit that referenced this issue Mar 28, 2016
@shu8 shu8 removed the help wanted label Mar 28, 2016
@shu8
Copy link
Member

shu8 commented Mar 28, 2016

fixed

@shu8 shu8 closed this as completed Mar 28, 2016
@shu8 shu8 removed the in progress label Mar 28, 2016
@mezmi mezmi reopened this Apr 2, 2016
@mezmi
Copy link
Contributor Author

mezmi commented Apr 2, 2016

@shu8

The version number is being injected, but, with that code running in a loop I am unable to type or select text from within the issue body.

The looped code should stop executing after the first successful injection of the version number.

We should also change the URL from github.com to github.com/soscripted/sox/issues/new and set a bool flag after it's ran.. What do you think?

@shu8
Copy link
Member

shu8 commented Apr 2, 2016

@enki-code

bool-flag, yes.

but if we change the match URL to that issue link, then it will only work if you land directly onto that page (remember the issue where you needed to refresh to make it work).

@shu8
Copy link
Member

shu8 commented Apr 2, 2016

@enki-code but it works for me... I can type and select... or do you mean somewhere else??

@mezmi
Copy link
Contributor Author

mezmi commented Apr 2, 2016

I was just coming to update my comment on the url.. you're right, that wouldn't work. 👍 In the issue body, I cannot type or select text because every 2 seconds the text is being replaced

@shu8
Copy link
Member

shu8 commented Apr 2, 2016

@enki-code Do you not have the return;? That should escape the setInterval..

setInterval(function() {
    if($('#issue_body').length) {
        var $issue = $('#issue_body'),
            issueText = $issue.text();
        issueText = issueText.replace('1.X.X', SOX_VERSION); //inject the SOX version by replacing the issue template's placeholder '1.X.X'
        issueText = issueText.replace('Chrome/Tampermonkey', SOX_MANAGER); //inject the SOX userscript manager+platfirm by replacing the issue template's placeholder 'Chrome/Tampermonkey'
        $issue.text(issueText);
   }
   // on GitHub, stop execution of the rest of the script.
   return;
}, 2000);

@shu8
Copy link
Member

shu8 commented Apr 2, 2016

Issue seems to have been random and neither of us can reproduce. Closing again...

@shu8 shu8 closed this as completed Apr 2, 2016
@mezmi
Copy link
Contributor Author

mezmi commented Apr 2, 2016

It was a glitch in the Matrix.

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

No branches or pull requests

2 participants