Patch: Search + Replace Tags (regexp)
![]() |
Thank you for your script, it saved me a lot of work. I thought it would be convenient to have Search + Replace functionality for tags, too. Moreover, I would like to use regular expressions for replacement, not just text. Here is a patch I made for myself and anyone who is interested. It adds "Search + Replace Tags (regexp)" link to the organizer page.
diff -Naur flickr_titles__descripti.orig/flickr_titles__descripti.user.js flickr_titles__descripti/flickr_titles__descripti.user.js
--- flickr_titles__descripti.orig/flickr_titles__descripti.user.js 2009-08-08 13:08:52.000000000 +0000
+++ flickr_titles__descripti/flickr_titles__descripti.user.js 2009-08-12 23:17:32.000000000 +0000
@@ -184,6 +184,16 @@
searchandreplacetitlesndesclink.setAttribute("href", "");
searchandreplacetitlesndesclink.addEventListener('click', searchandreplacetitlesndesclink_clickHandler, true);
searchandreplacetitlesndesclink.innerHTML = 'Search + Replace Titles+Descriptions';
+
+var searchandreplacetaglink_clickHandler = function(event) {
+ searchandreplace("Tag");
+ event.preventDefault();
+}
+
+var searchandreplacetaglink = document.createElement("a");
+searchandreplacetaglink.setAttribute("href", "");
+searchandreplacetaglink.addEventListener('click', searchandreplacetaglink_clickHandler, true);
+searchandreplacetaglink.innerHTML = 'Search + Replace Tags (regexp)';
/* new stuff */
@@ -197,6 +207,8 @@
toolsmenu.appendChild(document.createTextNode(' | '));
toolsmenu.appendChild(searchandreplacedesclink);
toolsmenu.appendChild(document.createTextNode(' | '));
+toolsmenu.appendChild(searchandreplacetaglink);
+toolsmenu.appendChild(document.createTextNode(' | '));
toolsmenu.appendChild(appendtotitlelink);
toolsmenu.appendChild(document.createTextNode(' | '));
toolsmenu.appendChild(appendtodesclink);
@@ -317,6 +329,14 @@
allTextareas[i].value = allTextareas[i].value.replace(repthis,reptext,'g');
}
}
+ if (command=="Tag") {
+ allTextareas = document.getElementsByTagName('input');
+ for (var i = 0; i < allTextareas.length; i++) {
+ if ((allTextareas[i].getAttribute('id')) && allTextareas[i].getAttribute('id').match(/^together_tags/)) {
+ allTextareas[i].value = allTextareas[i].value.replace(new RegExp(repthis),reptext,'g');
+ }
+ }
+ }
enablesavebutt();
The patch is for version 1.8. |
