Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show an adblock admonition in the dev console #3894

Merged
merged 3 commits into from Apr 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 21 additions & 2 deletions readthedocs/core/static-src/core/js/doc-embed/sponsorship.js
Expand Up @@ -106,9 +106,24 @@ Promo.prototype.post_promo_display = function () {
// Alabaster only
$('<hr />').insertBefore('#' + this.div_id + '.ethical-alabaster .ethical-footer');
}

};

function adblock_admonition() {
console.log('---------------------------------------------------------------------------------------');
console.log('Read the Docs hosts documentation for tens of thousands of open source projects.');
console.log('We fund our development (we are open source) and operations through advertising.');

console.log('We promise to:');
console.log(' - never let advertisers run 3rd party JavaScript');
console.log(' - never sell user data to advertisers or other 3rd parties');
console.log(' - only show advertisements of interest to developers');
console.log('Read more about our approach to advertising here: https://docs.readthedocs.io/en/latest/ethical-advertising.html');
console.log('Read more about Ads for Open Source: https://ads-for-open-source.readthedocs.io');
console.log('%cPlease whitelist Read the Docs on your adblocker using the following filter:', 'font-size: 2em');
console.log('https://ads-for-open-source.readthedocs.io/en/latest/_static/lists/readthedocs-ads.txt');
console.log('--------------------------------------------------------------------------------------');
}

function init() {
var request_data = {format: "jsonp"};
var div_ids = [];
Expand Down Expand Up @@ -164,8 +179,12 @@ function init() {
promo.display();
}
},
error: function () {
error: function (xhr, textStatus, errorThrown) {
console.error('Error loading Read the Docs promo');

if (xhr && xhr.status === 404 && rtd.api_host === 'https://readthedocs.org') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel like we probably need more of a check here. Is there an error thrown when it's blocked? In chrome I see "Blocked by the client" -- is there a specific error we should be looking for that is similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From jQuery's perspective, it is just a 404.

adblock_admonition();
}
},
});
}
Expand Down