Google Images Bypass Content Security Policy

Bypasses the Content Security Policy of websites that are blocking the website preview view on Google Images results. Otherwise you only see the mesage: Blocked by Content Security Policy. This page has a content security policy that prevents it from being loaded in this way. Firefox prevented this page from loading in this way because the page has a content security policy that disallows it.

  1. // ==UserScript==
  2. // @name Google Images Bypass Content Security Policy
  3. // @description Bypasses the Content Security Policy of websites that are blocking the website preview view on Google Images results. Otherwise you only see the mesage: Blocked by Content Security Policy. This page has a content security policy that prevents it from being loaded in this way. Firefox prevented this page from loading in this way because the page has a content security policy that disallows it.
  4. // @namespace cuzi
  5. // @oujs:author cuzi
  6. // @version 2
  7. // @license GPL-3.0
  8. // @include /^https?:\/\/images\.google\.\w{2,3}\//
  9. // @grant GM_xmlhttpRequest
  10. // ==/UserScript==
  11. (function() {
  12. function loadFrame(ev) {
  13. removeButton();
  14. var iframe = document.getElementById("il_f");
  15. GM_xmlhttpRequest({
  16. method: "GET",
  17. url: iframe.src,
  18. onload: function(response) {
  19. var charset = "utf-8";
  20. var re = /<meta charset=\"(.*?)\">/;
  21. var m = response.responseText.match(re);
  22. if(m && m[1]) {
  23. charset = m[1];
  24. }
  25. iframe.src = 'data:text/html;charset='+charset+',' + encodeURIComponent(response.responseText);
  26. }
  27. });
  28. }
  29. function addButton(ev) {
  30. button = document.createElement("button");
  31. button.appendChild(document.createTextNode("Bypass Content Security Policy"));
  32. button.setAttribute("style","font-size:150%; color:crimson;");
  33. button.addEventListener("click",loadFrame);
  34. document.getElementById("il_mi").insertBefore(button, document.getElementById("il_mi").firstChild);
  35. }
  36. function removeButton(ev) {
  37. if(button) {
  38. button.parentNode.removeChild(button);
  39. button = null;
  40. }
  41. }
  42. if(document.getElementById("il_f")) {
  43. var iframe = document.getElementById("il_f");
  44. var t0 = window.setTimeout(loadFrame,4000);
  45. var button;
  46. addButton();
  47. iframe.addEventListener("load",function(ev) {
  48. clearInterval(t0);
  49. });
  50. }
  51. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址