Closed KaKi87 closed 2 years ago
I don't think it makes sense to redirect codefactor.io as the site isn't a simple mirror.
Ok, maybe. It's just that I'm tired of seeing search results pointing to websites displaying data that doesn't belong to those.
Hm I understand. @vladgba what's your thought, should we add it?
@CennoxX Hi, I think we should add. But in the future, we need to add a mechanism to disable it if someone does not need a redirect.
I'm sorry to hear, hope you are safe. Yes, these pages are clones and not official mirrors, I'll add the pages.
@vladgba codefactor.io redirects always to the repository, even if a specific file is opened, which is a good, but not the best solution. Example: https://www.codefactor.io/repository/github/cennoxx/userscripts/file/main/scripts/Wikidata%20Episode%20Generator.user.js redirects to https://github.com/CennoxX/userscripts. There is a GitHub-link on file pages (Actions > View file on GitHub), but I can't get our script using this, as it isn't there on document-end, when back2source starts...
@CennoxX I'm sorry I didn't pay attention to that. Found some solution: (bad but working)
let sf = 'li[ng-if*="model.FileExternalUrl"]>a, a[ng-if*="model.FileExternalUrl"], a.page-title-link, a[title="GitHub"]';
let to = setTimeout(() => {
let dq = _t(sf);
if(dq?.href?.indexOf('github.com') >= 0) {
clearTimeout(to);
_go(dq.href);
}
}, 1000);
return;
have any ideas for improvement?
@vladgba I came up with another solution: wait for the document, then use normal selectors:
case 'codefactor.io':
document.addEventListener("DOMContentLoaded", (e)=>{
let sf = 'a[analytics-event^="View file on"]';
if (!_t(sf)){
sf = 'a[title^="View on"]';
}
if (_t(sf)){
return _go(bySel(sf));
}
});
break;
This works for GitHub and Bitbucket. It waits for the document, searches for "View file on ... (GitHub/Bitbucket)", if that's not there it searches for "View on ... (GitHub/Bitbucket)" and goes there, if it exists.
Thanks