1

I'm annoyed by our Ticketing System that always loads in the wrong view.

I wanted to fix this with a simple chrome extension that appends the required parameters to the ticket URL...

I found this solution:

Chrome Extension to Redirect to URL with Parameter

I can't get it working.. I imported the Extension (I see the Icon in Chrome) (I had a view issues with importing the manifest as my URL Permission weren't clear) Extension on the page looks like this: enter image description here

But the Icon in the Top-Right is greyed out - maybe that's normal?

My Mainfest looks like this:

{
  "manifest_version": 2,
  "name": "OTRS Fixer",
  "version": "0.1",
  "description": "Fixes OTRS View",

  "background": {
     "scripts": ["background.js"]
  },


 "page_action": {
    "default_icon": "icon.png"
  },

  "permissions": [
    "tabs",
    "webRequest",
    "http://ticket.domain.com/otrs/*",
    "webRequestBlocking"
  ]
}

My background.js file looks like this:

chrome.webRequest.onBeforeRequest.addListener(
    function(details) {
        return {
            redirectUrl: details.url + ";ZoomExpand=1"
        };
    },
    {urls: ['http://ticket.infotrust.ch/otrs/*"'], types: ['main_frame']},
    ['blocking']
);

An example URL that would need to be changed:

http://ticket.domain.com/otrs/index.pl?Action=AgentTicketZoom;TicketID=85377

Is there any way to check if my script gets executed? (Like can I add a pop-up message or something?)

I'm aware that my current script would just add it to the end, no matter what exact URL it is (and therefore break the website, but I just want to see it in action, the logic shouldn't be the problem)

Any help appreciated, it's my very first Extension (after the tutorials of course)

EDIT:

The "maybe" greyed out icon:

enter image description here

Michael
  • 289
  • 2
  • 5
  • 14
  • You can `console.log()` in the background page... which you can see by right clicking your extension icon and "Inspect Pop-up" – void Oct 19 '17 at 12:24
  • On your screenshot there's an "Inspect views: background page" thing, click on "background page" there, you can check what's being done in your background page there. – Walk Oct 19 '17 at 12:26
  • Unchecked runtime.lastError while running webRequestInternal.addEventListener: You do not have permission to use blocking webRequest listeners. Be sure to declare the webRequestBlocking permission in your manifest. at chrome-extension://aebpfcjbhblbfnadpeghdnhcklnihflg/background.js:1:35 – Michael Oct 19 '17 at 12:30
  • Added the requested permission, now there is no error, but still It doesn't take effect on the URL specified? :( – Michael Oct 19 '17 at 12:31
  • @void, I don't have a background page, as it's running in the background (no HTML-pop-up) – Michael Oct 19 '17 at 13:06
  • I suggest you read the [Chrome extension overview](https://developer.chrome.com/extensions/overview) (perhaps along with the pages linked from the overview). The [architecture section](https://developer.chrome.com/extensions/overview#arch) has overall architecture information which should help your understanding of how things are generally organized/done. – Makyen Oct 20 '17 at 20:55
  • @Michael, You *do* have a background page. You define it with `"background": { "scripts": ["background.js"] }`. A background page is implicitly created to contain your background script. – Makyen Oct 20 '17 at 20:57
  • What *exactly* is shown in the [various appropriate consoles for your extension](https://stackoverflow.com/a/38920982/3773011) when you load and execute your extension? – Makyen Oct 20 '17 at 20:57
  • Hi again, what it exactly says is ">" nothing more nothing less. In both ways, either opening it in extensions or on the website itself in console tab of developer tools. – Michael Oct 23 '17 at 08:01
  • and in the dropdown where "top" is, I can't find my extension – Michael Oct 23 '17 at 08:02
  • I have the same issue. – TheTechRobo the Nerd Jan 19 '21 at 19:50

0 Answers0