This is a follow up question on this question. Short version is: I'm trying to insert a dupe link (close vote as dupe here on Stack Overflow) into the textfield in the close vote popup using javascript (Chrome extension). The previous answer got me a bit further and seems the solutions. However the answer on that question works in console, but doesn't work in my chrome extension for some reason.
The problem is: when opening the vote to close popup here on Stack Overflow on a question and clicking the dupe reason. I can run the following code in the console:
var $dupeQuestion = $('#duplicate-question');
$dupeQuestion.val('https://stackoverflow.com/questions/8028957/headers-already-sent-by-php');
var e = $.Event('keydown', { keyCode: 64 });
$dupeQuestion.trigger(e);
And as already mentioned this works. The link is inserted into the textbox and the Stack Overflow JS kicks in to retrieve the question. However when I try to run that exact same code in my extension it only kinda works:
$(document).on('click', '.cvhelper-dupelist li', function() {
var $dupeQuestion = $('#duplicate-question');
$dupeQuestion.val('https://stackoverflow.com/questions/8028957/headers-already-sent-by-php');
var e = $.Event('keydown', { keyCode: 64 });
$dupeQuestion.trigger(e);
});
Kinda works means: the link is inserted in the textbox, but the Stack Overflow script to retrieve the question doesn't kick in. So I am totally clueless what could be wrong. Perhaps there is a difference somewhere when using console vs contentscript? Anything else?
I've created a download with a very simplified version of the extension at github.