6

Prior to submitting a post, I can see "Similar Questions", which I can click on to view questions issuing topics which the AI deems related to my post. Some of these may even not be related, but they might interest me. I may want to read them after I've posted my post.

How do I view the questions that interest me from the feed of "Similar Questions", after I've posted my post, (rather than before)?

I can click on Edit, in the list where my post shows up, but the list of Similar Questions no longer shows up.

1
  • 6
    Why don't you just open them in a new browser tab?
    – Luuklag
    Jan 1 at 8:03
8

I assume you mean the title search. There is no other place in the UI except for when asking a question to trigger a search that returns that specific list.

The normal search does have a title: directive but I can't make it return the same results as you'll find during asking a question. There is also a /similar endpoint in the Stacks API and it promises to do the same thing as the title search but in my testing that turned out not to be true.

Until a better option is discovered I've created this stack snippet that you can run. It will perform the exact same call as the /ask page does on a Glitch App and returns the same result.

You run the snippet, select a site from the drop down and then start typing in the search box, providing at least 15 characters.

function injectStacks() {
  var firstStyle = document.getElementsByTagName('style')[0];
  var stacksStyle = document.createElement('link');
  stacksStyle.href = 'https://unpkg.com/@stackoverflow/stacks/dist/css/stacks.min.css';
  stacksStyle.rel='stylesheet';
  document.getElementsByTagName('head')[0].insertBefore(stacksStyle, firstStyle);
}

function getSites() {
  return new Promise( (res,rej) => {
    fetch('https://api.stackexchange.com/2.3/sites?filter=!SnXC9o8IhkWHFg_YGr&pagesize=500&key=1*tsYg4Q3UbK06qftc8VmQ((')
      .then((resp)=> resp.json())
      .then((json) => {
        res(json.items);
    });
  })
}

var sites = document.getElementById('site');

getSites().then( (items) => {  
  items.forEach((item)=>{
    var option = document.createElement('option');
    option.textContent = item.name;
    option.setAttribute('data-url', item.site_url.substring(8));
    option.value = item.api_site_parameter;
    sites.appendChild(option);
  });
});

let timer = -1;
let title = document.getElementById('title');

function dofetch() {
  var siteurl = sites.selectedOptions[0].getAttribute('data-url');
  fetch('https://foamy-drip.glitch.me/search/titles?title='+ title.value + '&site='+ sites.value)
    .then((r) => r.json())
    .then((j) => {
      document.getElementById('content').innerHTML = j.content;
      document
        .getElementById('content')
        .querySelectorAll('a')
        .forEach( (a) => {
          var url = new URL(a.href);
          url.hostname = siteurl;
          a.href = url;
        });
      timer = -1;
    });
}

let lastvalue = '';

title.addEventListener('keyup', (e) => {
  if (lastvalue !== e.target.value && e.target.value.length > 14) {
    lastvalue = e.target.value;
    if (timer === -1) {
      timer = setTimeout(dofetch, 3000);
    }
  }
})

injectStacks();
/* CSS adapted from primary.css */

.question-summary {
    display: flex;
    padding: 12px 8px;
    float: none;
    width: 100%;
}

.started {
    padding-top: 4px;
    width: auto;
    float: right;
    line-height: 18px;
    font-size: 12px;
    margin-top: 4px;
}

.statscontainer {
    margin-right: 16px;
    width: 58px;
    float: none;
    margin-left: 8px;
    color: var(--black-500);
    font-size: 11px;
}
<label>site:<label><select id='site'>
</select>
<label>search:</label><input id='title' type='text' size='40' maxlength=200 />
<div>Updates every 3 seconds with a minimum of 15 characters</div>
<div id='content'>
</div>

Here is the server-side code to be run on NodeJs:

import fetch from 'node-fetch';
import express from "express";
const app = express();

app.get("/search/titles", function(request, response) {
  console.log(request.query);
  response.set('Access-Control-Allow-Origin', '*')
  if (request.query && 
      request.query.title && 
      request.query.title.length > 5 &&
      request.query.title.length < 250 &&
      request.query.site && 
      request.query.site.length < 45) {
    getSite(request.query.site)
      .then((i)=> {
        if (i) {
          fetch(i.site_url + '/search/titles?title=' + request.query.title)
            .then((resp)=> resp.json())
            .then((json)=> {response.send(json)})        
        } else {
          response.send({});        
        }
    } );
    
  } else {
    response.send({});
  }
});

let sites;

function getSites() {
  return new Promise( (res,rej) => {
    fetch('https://api.stackexchange.com/2.3/sites?filter=!*LBxCvVe1n2txvEz&pagesize=500&key='+process.env.SEKEY)
      .then((resp)=> resp.json())
      .then((json) => {
        console.log('loaded ', json.items.length)
        res(json.items);
    });
  })
}

function getSite(sitename) {
   return (sites || (sites = getSites())).then((allsites)=> {
     return allsites.find(e=> e.api_site_parameter === sitename);
   });
}

// listen for requests :)
const listener = app.listen(process.env.PORT, function() {
  console.log("Your app is listening on port " + listener.address().port);
});

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .