Link to Facebook Ad Library

try to take over the world!

  1. // ==UserScript==
  2. // @name Link to Facebook Ad Library
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://www.facebook.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. let url = document.URL
  14. let re1 = /&id=(\d+)/
  15. let re2 = /facebook\.com\/(\d+)/
  16. let page_id1 = url.match(re1)
  17. let page_id2 = url.match(re2)
  18. console.log("page_id2",page_id1)
  19. if (page_id1) {
  20. let ad_url=`https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=ALL&view_all_page_id=${page_id1[1]}&sort_data[direction]=desc&sort_data[mode]=relevancy_monthly_grouped`
  21. window.open(ad_url, "_blank")
  22. } else {
  23. let ad_url=`https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=ALL&view_all_page_id=${page_id2[1]}&sort_data[direction]=desc&sort_data[mode]=relevancy_monthly_grouped`
  24. window.open(ad_url, "_blank")
  25. }
  26.  
  27. })();