-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
@downloadURL
common values to Script Author Tools (#1680)
* Some Authors are copying the trailing `#` from raw view... so give them the correct ones for .user.js engines. Also inclusive of minification routine. Post #1654 and additional for #432 Auto-merge
- Loading branch information
Showing
6 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script type="text/javascript"> | ||
(function () { | ||
|
||
{{> includes/scripts/polyfillElementClosest.js }} | ||
|
||
function onClick(aEv) { | ||
aEv.preventDefault(); | ||
|
||
var containerNode = aEv.target.closest('li'); | ||
var listInstallTargets = document.querySelectorAll('#install-targets li'); | ||
var inputInstall = document.querySelector('#downloadurl'); | ||
var copyDownloadURLButton = document.querySelector('#downloadurl-raw'); | ||
var i = null; | ||
var thisItem = null; | ||
|
||
if (containerNode && listInstallTargets && inputInstall && copyDownloadURLButton) { | ||
inputInstall.value = aEv.target.title; | ||
copyDownloadURLButton.setAttribute( | ||
'data-clipboard-text', | ||
'// @downloadURL ' + aEv.target.title | ||
); | ||
|
||
for (i = 0; thisItem = listInstallTargets[i++];) { | ||
if (thisItem.classList.contains('active')) { | ||
thisItem.classList.remove('active'); | ||
} | ||
} | ||
|
||
containerNode.classList.add('active'); | ||
} | ||
} | ||
|
||
function onDOMContentLoaded(aEv) { | ||
var listInstallTargets = document.querySelectorAll('#install-targets li'); | ||
var thisItem = null; | ||
var i = null; | ||
var thisAnchor = null; | ||
|
||
for (i = 0; thisItem = listInstallTargets[i++];) { | ||
thisItem.addEventListener('click', onClick); | ||
|
||
thisAnchor = thisItem.querySelector('a'); | ||
|
||
if (thisAnchor.title === '{{script.meta.UserScript.downloadURL.0.value}}') { | ||
thisItem.classList.add('active'); | ||
} | ||
} | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', onDOMContentLoaded); | ||
|
||
})(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters