utterances icon indicating copy to clipboard operation
utterances copied to clipboard

allow for cross-origin iframe access or add support for reverse comment order

Open ar1ja opened this issue 2 years ago • 1 comments

hello utter devs

i want to implement reverse order of the comments in reverse on my site, but i cannot access the comments iframe bc of CORS :

Uncaught (in promise) DOMException: Permission denied to access property "document" on cross-origin object

i would make a pr, but no clue how the codebase works so lol

heres my code :

"use strict";

function sleep(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
}

async function main() {
    let comments = null;

    while (!comments) {
        comments = document.getElementsByClassName("utterances-frame")[0];
        await sleep(1000);
    }

    comments = comments.contentDocument || comments.contentWindow.document;

    console.log(comments);
}

// document.addEventListener("DOMContentLoaded", main);
main();

( also would be nice if yall added support for like utterences_on_load() or smt function so i wouldnt need that while loop lmao )

ar1ja avatar Jan 30 '23 14:01 ar1ja

related : https://github.com/utterance/utterances/issues/182

ar1ja avatar Jan 30 '23 14:01 ar1ja