Merge lp:~mcintire-evan/launchpad-gm-scripts/fix_button_tags into lp:launchpad-gm-scripts

Proposed by Evan McIntire
Status: Merged
Merged at revision: 181
Proposed branch: lp:~mcintire-evan/launchpad-gm-scripts/fix_button_tags
Merge into: lp:launchpad-gm-scripts
Diff against target: 62 lines (+21/-8)
1 file modified
lp_buttontags.user.js (+21/-8)
To merge this branch: bzr merge lp:~mcintire-evan/launchpad-gm-scripts/fix_button_tags
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+281559@code.launchpad.net

Description of the change

Fix lp_buttontags.user.js

At some point, GM_ functions began needing special permissions to run, which involved adding
    // @grant <function>
to the UserScript header

This change allows the functions to run again, which makes the script work again

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

While the script reacts after I click a tag, the tag does not seem to be added to the bug report. Even after a second reload of the page I do not see the tag I clicked on. Have you tested this on a bug report? If so what version of firefox were you using?

Revision history for this message
Evan McIntire (mcintire-evan) wrote :

My bad, I didn't fully test actually adding the tags. Is there a place I could do testing without messing with any actual bugs?

Revision history for this message
Brian Murray (brian-murray) wrote :

staging.launchpad.net seems to be down but qastaging.launchpad.net should work. However, you'll need to modify the @include to qastaging which is a good improvement anyway!

182. By Evan McIntire

Inject post() into the page and run it to bypass Greasemonkey sandboxing

183. By Evan McIntire

Actually commit the code

184. By Evan McIntire

Revert back to actual tags file

Revision history for this message
Brian Murray (brian-murray) wrote :

This works for me and it is possible to add tags again with this script. Thanks!

Revision history for this message
Brian Murray (brian-murray) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lp_buttontags.user.js'
--- lp_buttontags.user.js 2013-05-13 15:46:00 +0000
+++ lp_buttontags.user.js 2016-01-06 02:48:10 +0000
@@ -4,6 +4,9 @@
4// @description (Launchpad) Buttons for adding tags4// @description (Launchpad) Buttons for adding tags
5// @include https://bugs.launchpad.net/*/+bug/*5// @include https://bugs.launchpad.net/*/+bug/*
6// @include https://bugs.staging.launchpad.net/*/+bug/*6// @include https://bugs.staging.launchpad.net/*/+bug/*
7// @grant GM_getValue
8// @grant GM_setValue
9// @grant GM_xmlhttpRequest
7// ==/UserScript==10// ==/UserScript==
811
9// Feature Wishlist:12// Feature Wishlist:
@@ -42,12 +45,22 @@
4245
43// uses Launchpad javascript client to add data to bug tags46// uses Launchpad javascript client to add data to bug tags
44function post(data) {47function post(data) {
45 var lp_client = new LPJS.lp.client.Launchpad();48 //Very hacky way to work with Greasemonkey
46 var bug = new LPJS.lp.client.Entry(lp_client, LP.cache.bug, LP.cache.bug.self_link);49
47 bug.set('tags', data);50 //This function is injected and run in the context of the page, rather than the one Greasemonkey is in
48 bug.lp_save({on:{success:51 function injected(data) {
49 window.setTimeout(function() { window.location.reload() }, 3000)52 var lp_client = new LPJS.lp.client.Launchpad();
53 var bug = new LPJS.lp.client.Entry(lp_client, LP.cache.bug, LP.cache.bug.self_link);
54 bug.set('tags', data);
55 bug.lp_save({on:{success:
56 window.setTimeout(function() { window.location.reload() }, 3000)
50 }});57 }});
58 }
59
60 //Injects the above function into the page
61 var script = document.createElement('script');
62 script.appendChild(document.createTextNode('('+injected+')(["'+data.join('","')+'"])'));
63 (document.body).appendChild(script);
51}64}
5265
53// Retrieves url using HTTP GET, then calls the function cb with the response text as its single argument.66// Retrieves url using HTTP GET, then calls the function cb with the response text as its single argument.
@@ -238,7 +251,7 @@
238 return;251 return;
239 }252 }
240253
241 tags_current_list[tags_current_list.length] = this.id;254 tags_current_list.unshift(this.id);
242 post(tags_current_list);255 post(tags_current_list);
243 // don't reload right away because the tag update post needs to finish256 // don't reload right away because the tag update post needs to finish
244 //window.setTimeout(function() { window.location.reload() }, 1200);257 //window.setTimeout(function() { window.location.reload() }, 1200);
@@ -281,8 +294,8 @@
281 }294 }
282 else {295 else {
283 displayTags();296 displayTags();
284 } 297 }
285298
286}, false); 299}, false);
287300
288})();301})();
289\ No newline at end of file302\ No newline at end of file

Subscribers

People subscribed via source and target branches