Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH Anonymize Analytics and remove former google search#19

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
thomasjpfan wants to merge1 commit intoscikit-learn:main
base:main
Choose a base branch
Loading
fromthomasjpfan:remove_google_analytics

Conversation

thomasjpfan
Copy link
Member

@thomasjpfanthomasjpfan commentedFeb 14, 2022
edited
Loading

This is the script I ran to find and replace or remove the javascript

Script
frompathlibimportPathroot_path=Path(".")old_analytics="""    <script type="text/javascript">      var _gaq = _gaq || [];      _gaq.push(['_setAccount', 'UA-22606712-2']);      _gaq.push(['_trackPageview']);      (function() {        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);      })();    </script>"""new_analytics="""<script>    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;    ga('create', 'UA-22606712-2', 'auto');    ga('set', 'anonymizeIp', true);    ga('send', 'pageview');</script><script async src='https://www.google-analytics.com/analytics.js'></script>"""search_control1="""    <script src="http://www.google.com/jsapi" type="text/javascript"></script>    <script type="text/javascript"> google.load('search', '1',        {language : 'en'}); google.setOnLoadCallback(function() {            var customSearchControl = new            google.search.CustomSearchControl('016639176250731907682:tjtqbvtvij0');            customSearchControl.setRiesultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);            var options = new google.search.DrawOptions();            options.setAutoComplete(true);            customSearchControl.draw('cse', options); }, true);    </script>"""search_control2="""    <script>      (function() {        var cx = '016639176250731907682:tjtqbvtvij0';        var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;        gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);      })();    </script>"""search_controls= (search_control1,search_control2)forfileinroot_path.glob("**/*.html"):contents=file.read_text()new_contents=Noneifold_analyticsincontents:new_contents=contents.replace(old_analytics,new_analytics)forsearch_controlinsearch_controls:ifsearch_controlincontents:new_contents=contents.replace(search_control,"")ifnew_contentsisNone:continueprint(f"Writing to file:{file}")file.write_text(new_contents)

jjerphan reacted with eyes emoji
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@thomasjpfan

[8]ページ先頭

©2009-2025 Movatter.jp