diff --git a/improved-tag-popup/README.md b/improved-tag-popup/README.md
new file mode 100644
index 0000000..a4d4902
--- /dev/null
+++ b/improved-tag-popup/README.md
@@ -0,0 +1,18 @@
+# Improved Tag Popup
+
+Inspired by [this feature request by Andrew Leach](https://meta.stackexchange.com/q/314150/295232),
+this script adds some extra links in the new tag popup,
+to view and edit the full tag information (wiki and excerpt).
+
+![](example.png)
+
+## Installation
+
+- Install the userscript with
+[this direct link](https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/improved-tag-popup/improved-tag-popup.user.js).
+
+developed & tested with Violentmonkey on Firefox
+
+## Support
+
+If you have any questions, please post a comment on [this Stack Apps question](https://stackapps.com/q/8054/34061).
diff --git a/improved-tag-popup/example.png b/improved-tag-popup/example.png
new file mode 100644
index 0000000..f1fa1fa
Binary files /dev/null and b/improved-tag-popup/example.png differ
diff --git a/improved-tag-popup/improved-tag-popup.user.js b/improved-tag-popup/improved-tag-popup.user.js
index 58b512f..eeb9c39 100644
--- a/improved-tag-popup/improved-tag-popup.user.js
+++ b/improved-tag-popup/improved-tag-popup.user.js
@@ -5,7 +5,7 @@
// @author Glorfindel
// @updateURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/improved-tag-popup/improved-tag-popup.user.js
// @downloadURL https://raw.githubusercontent.com/Glorfindel83/SE-Userscripts/master/improved-tag-popup/improved-tag-popup.user.js
-// @version 0.1
+// @version 0.2
// @match *://*.stackexchange.com/*
// @match *://*.stackoverflow.com/*
// @match *://*.superuser.com/*
@@ -17,14 +17,41 @@
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// ==/UserScript==
+// from https://stackoverflow.com/a/21249710/4751173
+$.fn.ownText = function() {
+ return this.eq(0).contents().filter(function() {
+ return this.nodeType === 3 // && $.trim(this.nodeValue).length;
+ }).map(function() {
+ return this.nodeValue;
+ }).get().join('');
+}
+
waitForKeyElements("div.tag-popup", function(jNode) {
jNode.find("a").filter(function() {
return $(this).text() === "View tag";
}).each(function() {
+ let tagName = $(this).attr("href").split("/").pop();
+ let hasInfo = $(this).parent().ownText().trim().length > 0;
+ if (hasInfo) {
+ $("
").insertBefore($(this));
+ }
+
+ // Other questions
$(this).text("Other questions");
- var tagName = $(this).attr("href").split("/").pop();
- $("
").insertBefore($(this));
- $("More info").insertBefore($(this));
+
+ // More info
+ let infoURL = "/tags/" + tagName + "/info";
+ $("More info").insertBefore($(this));
+ $(" | ").insertBefore($(this));
+
+ // Edit/add info
+ let editLink = $("" + (hasInfo ? "Edit" : "Add") + " info");
+ editLink.click(function() {
+ $.get(infoURL, function(data) {
+ window.location.href = $(data).find("a[href^='/edit-tag-wiki/']").attr("href");
+ });
+ });
+ editLink.insertBefore($(this));
$(" | ").insertBefore($(this));
});
})
\ No newline at end of file