• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    take taburl from current tab

    Opera for Linux
    1
    1
    814
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • estatistics
      estatistics last edited by estatistics

      I have downloaded a chrome extension for opera browser.
      "https://github.com/zeyad-shaban/image-handling-shortcuts/issues"

      I like to modify it in order to display the url of current active tab in his "html info page" (popup.html) to use it later for other things.

      in manifest.json (the permisions)

      "permissions": [ "tabs", "activeTab" ]
      

      in popup.html (in body somewhere)

      <span id="url"></span>
       <script src="popup.js"></script>
      

      popup.js (all of it)

      function _getCurrentTab(callback){ //Take a callback
            var theTab;
            chrome.tabs.query({active:true, currentWindow:true},function(tab){
                callback(tab); //call the callback with argument
            });
        };
        _displayTab(tab){ //define your callback function
            console.log(tab);
      };
      
      _getCurrentTab(_displayTab); //invoke the function with the callback function reference
      
      async function getCurrentTabUrl () {
      const tabs = await opera.tabs.query({ active: true })
      return tabs[0].url
      }
      
      getCurrentTabUrl ();
      
      async function getCurrentTaba() {
      let queryOptions = { active: true, lastFocusedWindow: true };
      let [tab] = await opera.tabs.query(queryOptions);
      return tabs[0].url;
      }
      
      
      getCurrentTaba();
      
      async function getTab() {
      let queryOptions = { active: true, currentWindow: true };
      let tabs = await chrome.tabs.query(queryOptions);
      return tabs[0].url;
      }
      
      
      getTab();
      
      chrome.tabs.onUpdated.addListener(function () {
        console.log("TAB UPDATED")
        getTab().then(url => {
            console.log(url);
        })
      })
      
      chrome.action.onClicked.addListener((tab) => {
      console.log(tab.url);
      });
      
      chrome.action.onClicked.addListener(function(tab) {
      // No tabs or host permissions needed!
      console.log('Turning ' + tab.url + ' red!');
      chrome.scripting.executeScript({
        code: 'document.body.style.backgroundColor="red"'
      });
      });
      
      chrome.browserAction.onClicked.addListener(function() {
        chrome.tabs.create({
        	'url': 'https://www.opera.com'
        });
      });
      

      all these code functions taken from various places in web dontwork. When i click on the icon of the extention, (popup.html) do not display current tab url.

      I have tried similar different snipsets with no success. What is going wrong?

      What i must change in order to display the url of current tab in its info html page?

      Reply Quote 0
        1 Reply Last reply
      • Locked by  leocg leocg 
      • First post
        Last post

      Computer browsers

      • Opera for Windows
      • Opera for Mac
      • Opera for Linux
      • Opera beta version
      • Opera USB

      Mobile browsers

      • Opera for Android
      • Opera Mini
      • Opera Touch
      • Opera for basic phones

      • Add-ons
      • Opera account
      • Wallpapers
      • Opera Ads

      • Help & support
      • Opera blogs
      • Opera forums
      • Dev.Opera

      • Security
      • Privacy
      • Cookies Policy
      • EULA
      • Terms of Service

      • About Opera
      • Press info
      • Jobs
      • Investors
      • Become a partner
      • Contact us

      Follow Opera

      • Opera - Facebook
      • Opera - Twitter
      • Opera - YouTube
      • Opera - LinkedIn
      • Opera - Instagram

      © Opera Software 1995-2025