Stop watching all the pages in space
Asked by Ryota Hashimoto:

Hi,

I have a bunch of watching pages and want to stop all. Is there a way for bulk execution of that, instead of opening each page and stop watching one by one?

Thanks,


Answers:
author: Sachin
body: Hello [@Ryota Hashimoto](/t5/user/viewprofilepage/user-id/3114806) , on top right corner --\> Goto --\> Profile --\> Settings --\> Watches --\> From here you can click "Stop Watching" for any unwanted spaces or pages you like.  

You can also adjust your email notification options from your email settings  
https://yourinstancename/wiki/users/viewmyemailsettings.action page or goto --\> your profile --\> Settings --\> Email --\> Edit --\> Turn off Autowatch

comments: author: Ryota Hashimoto
body: Hi Sachin thank you for your help.

I found the Watches page and will stop them one by one since I'm still afraid there are no bulk way to do them at once.

Also the autowatch info helped me while I need that feature in usual case but not applied on this case since I've made bunch of pages by add-on.

Thanks,


author: Stefan Ey
body: If you have many watches because you imported a lot of pages it is messy to stop all the watches step by step.

I wrote a simple bookmarklet so I can stop all watches on the page with just one click and the page will reload as well.

For example, if you have 30 watch pages, you only need 30 clicks to stop them all.

This is the js-code of the bookmarklet:

```
javascript: void (function () {

    document.getElementsByClassName('link-stop-watching').forEach(b => b.click());

    location.reload();

})();
```

comments: author: Maria Murphy
body: You are my hero! I had 60+ pages of these to deal with. Much gratitude from a Confluence administrator...


author: Julian from AF
body: Hi can you descrire how use this?? Thank you


author: Stefan Ey
body: Ask Google what a bookmarklet is and how to use it. The bookmarklet code is above.


author: Julian from AF
body: It's working !! I was 26 pages of pages... All removed in 1 minute. Thank you


author: Anja Zhuchkova
body: HI [@Stefan Ey](/t5/user/viewprofilepage/user-id/4759595)

Does that work for Confluence Cloud too?


author: Stefan Ey
body: I don't know - we are using the server version. But I think the frontend in the browser should be the same or very similar and it could work fine.


author: Brett Neilson
body: This saved me a ton of time! I had well over 200 pages that I was watching and within a few clicks that was resolved.


author: Kirk Bratvold
body: It didn't work for me using Chrome v106 and Confluence Cloud, until I changed it to this:

javascript\&colon; void (function () { const el=document.getElementsByClassName('link-stop-watching'); \[...el\].forEach(b =\> b.click()); location.reload(); })();


author: Anja Zhuchkova
body: [@Kirk Bratvold](/t5/user/viewprofilepage/user-id/3994816) if I copy your script, the error "incorrect URL" appears. Any ideas on how to solve that?


author: Kimberly Onnen
body: This saved me SO much time... I had 85 pages of topics to "unwatch". Thank you!


author: Warren S
body: This was a life saver, the refresh action didn't work for me on Chrome v109.0.5414.75, but a click and an F5 did the trick. A few minutes later Im watch free. Thanks again!


author: Stefan Ey
body: I wrote a little HTML test file and I have discovered that the page reload was faster than the execution of the simulated clicks on the \<\<Stop Watching\>\> buttons.

I have **improved** the bookmarklet code. Here is the **new version** that**works fine** on my Confluence profile. If needed you can increase the timeout value - here 2000.

Happy coding or working ;-)

```
javascript&colon;(function () {
      document.getElementsByClassName('link-stop-watching').forEach(b => b.click());
      setTimeout(() => location.reload(), 2000);
})();
```

Due the code box above works not well, you have to replace the ***\&colon;*** after the leading javascript with ***:***


author: Danilo Castro Borges
body: Wow, this solution was amazing, I had 40 pages topics to "unwatch". Very nice, Thank you!


author: Mark Leci
body: I got an error using all the previous examples - here's a bookmarklet that worked for me with Confluence Cloud from the wiki/users/viewnotifications.action page. I also reduced the reload time because I had 45 pages of links to click!

javascript\&colon;window.onload=(function () {const elementAr = document.getElementsByClassName('link-stop-watching');const Ar = Array.from(elementAr);Ar.forEach(b =\> {b.click()});setTimeout(() =\> location.reload(), 500);})();


author: Stefan Ey
body: You mean you lose precious 45 x 2 seconds = 1.5 minutes of your lifetime? What will you do with the saved minute? It's a free world ;-)


author: Thierry BLOCH
body: Thank you Mark Leci, it's worked for me (replacing the ***\&colon;*** after the leading javascript with ***:*** )


author: M Hoogenboom
body: This is brilliant. Many thanks for this.


author: Matt C. Wilson
body: Here is a boosted version of the script that allows you to target only a particular space.  

In my case, my role changed at my company such that I handed off ownership of a space I'd maintained for a *long* time and authored hundreds of pages in.  

I wanted to stop watching every single one of *that space's* pages, but keep my other watches.  

The way this script works:  

The code below builds a function called "go" that takes two parameters:

1. specific "searchText" for the space name(s) to match
2. a "live" boolean that *must* be set "true" for the function to auto-click links.

So, leaving the "live" parameter out or setting it "false" lets you check what would be done without doing it.

```
function go(searchText, live) {
  var ixs = [];
  var logmsg = "would stop: ";

  if (live) {
    logmsg = "stopping: ";
  }

  var spans = $("#page-watches tr td span.smalltext");
  spans.each((k, v) => { if (v.textContent.includes(searchText)) { ixs.push(k) } } );

  console.log(ixs.join(", "));

  var as = $("#page-watches tr td.tableview-action-icon div a:not('.hidden')");

  console.log(as.length);

  as.each((k, v) => { if (ixs[0] == k) { ixs.shift(); if (v.classList.contains("link-stop-watching")) { console.log(logmsg + k); if (live) { v.click(); } } } } );

  if (live) { setTimeout(() => location.reload(), 2000); }
}
```

So, for example, if you want to bulk unwatch all pages for spaces with "Foo" in their name, you would first paste the above function into your browser console, and then run:

```
go("Foo");   // shows you which links it would click using their index position

go("Foo", true); // clicks those particular stop watching links, ignores others
```

Note: you will need to re-paste the function after the page reloads. You may also run into a point where all 20 links on the Watches page you are on are not hits. In that case, you will need to manually navigate to the next page, paste, and run again.

comments: author: Stefan Ey
body: Inspired by your post I have rewritten my bookmarklet code, thus only watches of a specific space are removed. The user is asked for the space name, which is temporarily stored until the last page is processed by executing this bookmarklet.

```
javascript&colon; void (function () { ? 
? ? var tbl = document.getElementById('page-watches');
```

```
    var tblRows = tbl.tBodies[0].rows;
    var rowsCount = tblRows.length;
    var itemName = 'watchSpacePattern';

    if(rowsCount > 0) {        
        var spacePattern = localStorage.getItem(itemName);
        if (spacePattern == undefined) {
            spacePattern = '(' + prompt('Enter the space name for which you want to delete the watches.') + ')';
            localStorage.setItem(itemName, spacePattern);
        }
        tblRows.forEach(rw => {
            var spaceName = rw.cells[0].children[2].textContent;
            if (spaceName == spacePattern) {
                rw.cells[1].children[0].children.forEach(ch => {
                    if(ch.textContent == 'Stop Watching'){ 
                        ch.click(); 
                    }
                })
            }
        });    
        if(rowsCount < 20) {
            localStorage.removeItem(itemName); 
        }
        setTimeout(() => location.reload(), 1000);    
    } else { 
        localStorage.removeItem(itemName); 
    }
})();

```

Happy coding ;-)


author: Stefan Ey
body: Now that we have moved from the company server to the Atlassian cloud, the bookmarklet code no longer works in the cloud. Since an *HTMLCollection* is returned instead of an array when collecting the watches, iteration using *forEach* is no longer possible.  

Thus I reworked the bookmarklet code:

```
javascript&colon; void (function () {let links=document.getElementsByClassName('link-stop-watching'); for(i=0;i<links.length;i++){links[i].click();} setTimeout(() => location.reload(), 1000);})();
```

It should also work with the server version, but I can't test it anymore.  

Good luck


author: efavreau
body: I wrote this up a while ago (February 3, 2022), borrowing from a deleted user, and I still use it. I know a couple other people told me it worked for them too.  

It will help with:  
\* Watched pages  
\* Watched spaces  
\* Save for Later  
\* Drafts  

<https://community.atlassian.com/t5/Confluence-discussions/Bulk-removing-your-Watched-pages-spaces-Save-for-Later-and/td-p/1933623>


author: Andreas Purde
body: My original posting does not help as you are on cloud sorry.

comments: author: Ryota Hashimoto
body: np thanks a lot!


Tags: cloud